iffyio commented on code in PR #1459: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1459#discussion_r1792185691
########## src/ast/mod.rs: ########## @@ -646,12 +646,16 @@ pub enum Expr { regexp: bool, }, /// `ANY` operation e.g. `foo > ANY(bar)`, comparison operator is one of `[=, >, <, =>, =<, !=]` + /// https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#_8_9_quantified_comparison_predicate Review Comment: I'm thinking we can link to [snowflake](https://docs.snowflake.com/en/sql-reference/operators-subquery#all-any) instead? Since that's a supported dialect that has the subquery functionality. The current link doesnt seem to refer to any specific dialect so it could add confusion later on when trying to figure what features in the parser to maintain ########## src/parser/mod.rs: ########## @@ -2639,10 +2632,22 @@ impl<'a> Parser<'a> { }; if let Some(op) = regular_binary_operator { - if let Some(keyword) = self.parse_one_of_keywords(&[Keyword::ANY, Keyword::ALL]) { + if let Some(keyword) = + self.parse_one_of_keywords(&[Keyword::ANY, Keyword::ALL, Keyword::SOME]) + { self.expect_token(&Token::LParen)?; - let right = self.parse_subexpr(precedence)?; - self.expect_token(&Token::RParen)?; + let right = if self.is_query_ahead() { + // We have a subquery ahead (SELECT\WITH ...) need to rewind and + // use the parenthesis for parsing the subquery as an expression. + self.prev_token(); // SELECT + self.prev_token(); // LParen + self.parse_subexpr(precedence)? Review Comment: Ah right that makes sense! ########## src/ast/mod.rs: ########## @@ -650,6 +650,8 @@ pub enum Expr { left: Box<Expr>, compare_op: BinaryOperator, right: Box<Expr>, + // ANY and SOME are synonymous Review Comment: Ah cool! Can we include the link in the comment here as well? It could help later on in case someone comes across this and wonders the same -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@datafusion.apache.org For additional commands, e-mail: dev-h...@datafusion.apache.org