sabir-akhadov-localstack commented on code in PR #2854:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2854#discussion_r4695725575
##########
src/dialect/generic.rs:
##########
@@ -137,6 +137,10 @@ impl Dialect for GenericDialect {
true
}
+ fn supports_values_subquery_expr(&self) -> bool {
Review Comment:
With Generic opted in, the parenthesised MySQL form regresses there: `INSERT
INTO t (a) VALUES (1) ON DUPLICATE KEY UPDATE a = (VALUES(a) + 1)` parsed on
main and now fails with `Expected: ), found: +`, and `a = (VALUES(a))` becomes
a subquery instead of the function call. Maybe leave Generic out, or fall back
to the expression parse when the subquery attempt fails?
##########
src/parser/mod.rs:
##########
@@ -22503,10 +22503,12 @@ impl<'a> Parser<'a> {
self.tokens
}
- /// Returns true if the next keyword indicates a sub query, i.e. SELECT or
WITH
+ /// Returns true if the next keyword indicates a sub query, i.e. SELECT or
WITH,
+ /// or VALUES where [`Dialect::supports_values_subquery_expr`] holds
fn peek_sub_query(&mut self) -> bool {
self.peek_one_of_keywords(&[Keyword::SELECT, Keyword::WITH])
.is_some()
+ || (self.dialect.supports_values_subquery_expr() &&
self.peek_keyword(Keyword::VALUES))
Review Comment:
`parse_set_values` also goes through this check without a preceding `(`, so
`SET search_path = values, public` (accepted by PG 16 and by main) now fails
with `Expected: (, found: ,`.
--
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]