sabir-akhadov-localstack opened a new pull request, #2387:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2387

   When parsing `INSERT INTO t <source>`, the parser must decide whether the 
tokens following the table name begin an explicit column list `(a, b, ...)` or 
the source query `(SELECT ...)`. It made this decision in `peek_subquery_start` 
by matching exactly `( SELECT`, so a source query wrapped in more than one 
layer of parentheses was mistaken for a column list and failed to parse. For 
example `INSERT INTO t ((SELECT 1))` errored out, even though the equivalent 
nested-parenthesized subquery parses fine in other positions.
   
   This changes `peek_subquery_start` to skip any number of leading `(` and 
treat the tokens as a subquery start as long as at least one paren precedes the 
`SELECT`. That makes INSERT consistent with the way nested parentheses around 
subqueries are already handled elsewhere via recursive descent.
   
   A regression test is added in `tests/sqlparser_common.rs` covering `INSERT 
INTO t ((SELECT 1))` and `INSERT INTO t (((SELECT 1)))`; both round-trip and 
the column list is empty.


-- 
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]

Reply via email to