(&mut self)
| 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])? { |
no test coverage detected