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

Method parse_cte_mut_rec

src/sql-parser/src/parser.rs:7703–7723  ·  view source on GitHub ↗

Parse a mutually recursive CTE (`alias ( col1: typ1, col2: typ2, ... ) AS (subquery)`). The main distinction from `parse_cte` is that the column names and types are mandatory. This is not how SQL works for `WITH RECURSIVE`, but we are doing it for now to make the query interpretation that much easier.

(&mut self)

Source from the content-addressed store, hash-verified

7701 /// This is not how SQL works for `WITH RECURSIVE`, but we are doing it for now to make the
7702 /// query interpretation that much easier.
7703 fn parse_cte_mut_rec(&mut self) -> Result<CteMutRec<Raw>, ParserError> {
7704 let name = self.parse_identifier()?;
7705 self.expect_token(&Token::LParen)?;
7706 let columns = self.parse_comma_separated(|parser| {
7707 Ok(CteMutRecColumnDef {
7708 name: parser.parse_identifier()?,
7709 data_type: parser.parse_data_type()?,
7710 })
7711 })?;
7712 self.expect_token(&Token::RParen)?;
7713 self.expect_keyword(AS)?;
7714 self.expect_token(&Token::LParen)?;
7715 let query = self.parse_query()?;
7716 self.expect_token(&Token::RParen)?;
7717 Ok(CteMutRec {
7718 name,
7719 columns,
7720 query,
7721 id: (),
7722 })
7723 }
7724
7725 /// Parse a "query body", which is an expression with roughly the
7726 /// following grammar:

Callers

nothing calls this directly

Calls 6

parse_identifierMethod · 0.80
expect_tokenMethod · 0.80
parse_comma_separatedMethod · 0.80
parse_data_typeMethod · 0.80
expect_keywordMethod · 0.80
parse_queryMethod · 0.45

Tested by

no test coverage detected