ksaiharshavinay opened a new issue, #2895:
URL: https://github.com/apache/datafusion-sqlparser-rs/issues/2895

   ### Summary
   
   `sqlparser-rs` parses wildcard options (`EXCLUDE` / `EXCEPT` / `RENAME` / 
`REPLACE`) in a single fixed-order pass, so a wildcard that puts `RENAME` 
before `REPLACE` fails to parse — even though both orders are valid SQL. The 
parser rejects SQL that Snowflake accepts.
   
   ### Failing statement
   
   ```sql
   SELECT * RENAME (a AS b) REPLACE (a + 1 AS a) FROM (SELECT a FROM t)
   ```
   
   Snowflake dialect. The reverse order parses fine:
   
   ```sql
   SELECT * REPLACE (a + 1 AS a) RENAME (a AS b) FROM (SELECT a FROM t)
   ```
   
   ### Expected vs actual
   
   - Expected: the statement parses under `SnowflakeDialect`, with both 
modifier orders accepted.
   - Actual: parse error on the reversed modifier order: `sql parser error: 
Expected: end of statement, found: REPLACE`.
   
   Verified against current `main` (crate version 0.64.0, commit bac1468b); the 
limitation is also present in 0.63. The existing test 
`test_select_wildcard_with_replace_and_rename` in 
`tests/sqlparser_snowflake.rs` currently pins the reversed order as an expected 
error.
   
   ### Suggested fix
   
   Accept the wildcard options in any order in 
`parse_wildcard_additional_options`, instead of a single fixed-order pass.
   
   ### Context
   
   Discovered during the OpenLineage PR OpenLineage/OpenLineage#5136 review 
work (star-over-subquery lineage, `SELECT *` over derived tables with 
`EXCLUDE`/`EXCEPT`/`RENAME`/`REPLACE` modifiers), where the reversed order is 
pinned as a known-failure test. OpenLineage reviewer @lhadhazy, on signing off 
that PR, flagged this as worth filing upstream in sqlparser-rs, since it is the 
parser rejecting SQL that Snowflake accepts.
   


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