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

Method parse_subscribe

src/sql-parser/src/parser.rs:8876–8912  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

8874 }
8875
8876 fn parse_subscribe(&mut self) -> Result<Statement<Raw>, ParserError> {
8877 let _ = self.parse_keyword(TO);
8878 let relation = if self.consume_token(&Token::LParen) {
8879 let query = self.parse_query()?;
8880 self.expect_token(&Token::RParen)?;
8881 SubscribeRelation::Query(query)
8882 } else {
8883 SubscribeRelation::Name(self.parse_raw_name()?)
8884 };
8885 let mut output = self.parse_subscribe_output()?;
8886 let options = if self.parse_keyword(WITH) {
8887 self.expect_token(&Token::LParen)?;
8888 let options = self.parse_comma_separated(Self::parse_subscribe_option)?;
8889 self.expect_token(&Token::RParen)?;
8890 options
8891 } else {
8892 vec![]
8893 };
8894 let as_of = self.parse_optional_as_of()?;
8895 let up_to = self.parse_optional_up_to()?;
8896 // For backwards compatibility, we allow parsing output options
8897 // (`ENVELOPE`, `WITHIN TIMESTAMP ORDER BY`) at the end of the
8898 // statement, if they haven't already been specified where we prefer
8899 // them, before the `WITH` options and before the `AS OF`/`UP TO`
8900 // options. Our preferred syntax better aligns with the option ordering
8901 // for `CREATE SINK` and `SELECT`.
8902 if output == SubscribeOutput::Diffs {
8903 output = self.parse_subscribe_output()?;
8904 }
8905 Ok(Statement::Subscribe(SubscribeStatement {
8906 relation,
8907 options,
8908 as_of,
8909 up_to,
8910 output,
8911 }))
8912 }
8913
8914 fn parse_subscribe_option(&mut self) -> Result<SubscribeOption<Raw>, ParserError> {
8915 let name = match self.expect_one_of_keywords(&[PROGRESS, SNAPSHOT])? {

Callers 2

parse_statement_innerMethod · 0.80
parse_explaineeMethod · 0.80

Calls 12

parse_keywordMethod · 0.80
consume_tokenMethod · 0.80
expect_tokenMethod · 0.80
parse_raw_nameMethod · 0.80
parse_comma_separatedMethod · 0.80
parse_optional_as_ofMethod · 0.80
parse_optional_up_toMethod · 0.80
QueryClass · 0.50
NameClass · 0.50
SubscribeClass · 0.50
parse_queryMethod · 0.45

Tested by

no test coverage detected