MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_source_columns

Method parse_source_columns

src/sql-parser/src/parser.rs:3266–3289  ·  view source on GitHub ↗

Parses the column section of a CREATE SOURCE statement which can be empty or a comma-separated list of column identifiers and a single key constraint, e.g. (col_0, col_i, ..., col_n, key_constraint)

(&mut self)

Source from the content-addressed store, hash-verified

3264 ///
3265 /// (col_0, col_i, ..., col_n, key_constraint)
3266 fn parse_source_columns(&mut self) -> Result<(Vec<Ident>, Option<KeyConstraint>), ParserError> {
3267 if self.consume_token(&Token::LParen) {
3268 let mut columns = vec![];
3269 let mut key_constraints = vec![];
3270 loop {
3271 let pos = self.peek_pos();
3272 if let Some(key_constraint) = self.parse_key_constraint()? {
3273 if !key_constraints.is_empty() {
3274 return parser_err!(self, pos, "Multiple key constraints not allowed");
3275 }
3276 key_constraints.push(key_constraint);
3277 } else {
3278 columns.push(self.parse_identifier()?);
3279 }
3280 if !self.consume_token(&Token::Comma) {
3281 break;
3282 }
3283 }
3284 self.expect_token(&Token::RParen)?;
3285 Ok((columns, key_constraints.into_iter().next()))
3286 } else {
3287 Ok((vec![], None))
3288 }
3289 }
3290
3291 /// Parses a key constraint.
3292 fn parse_key_constraint(&mut self) -> Result<Option<KeyConstraint>, ParserError> {

Callers 1

parse_create_sourceMethod · 0.80

Calls 9

consume_tokenMethod · 0.80
peek_posMethod · 0.80
parse_key_constraintMethod · 0.80
parse_identifierMethod · 0.80
expect_tokenMethod · 0.80
is_emptyMethod · 0.45
pushMethod · 0.45
nextMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected