sabir-akhadov-localstack commented on code in PR #2772:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2772#discussion_r4425351001
##########
src/parser/mod.rs:
##########
@@ -1620,12 +1620,16 @@ impl<'a> Parser<'a> {
Keyword::TRY_CAST =>
Ok(Some(self.parse_cast_expr(CastKind::TryCast)?)),
Keyword::SAFE_CAST =>
Ok(Some(self.parse_cast_expr(CastKind::SafeCast)?)),
Keyword::EXISTS
- // Support parsing Databricks has a function named `exists`.
- if !dialect_of!(self is DatabricksDialect)
+ // A query after the parenthesis is still the EXISTS predicate.
+ if !self.dialect.supports_exists_function()
|| matches!(
self.peek_nth_token_ref(1).token,
Token::Word(Word {
- keyword: Keyword::SELECT | Keyword::WITH,
+ keyword: Keyword::SELECT
+ | Keyword::WITH
+ | Keyword::TABLE
+ | Keyword::VALUES
+ | Keyword::FROM,
Review Comment:
A parenthesised query is also a query: `SELECT EXISTS ((SELECT 1) UNION
(SELECT 2))` parses as `Expr::Exists` on Spark today and fails on this branch
(`Expected: ), found: UNION`); `EXISTS ((SELECT 1))` becomes a function call.
Adding `Token::LParen` to the peek (or trying `parse_exists_expr` first and
falling back to the function call) would keep that. Related: `NOT exists(arr, x
-> x > 1)` still fails because `parse_not` routes `NOT EXISTS` straight to
`parse_exists_expr` without consulting the new hook.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]