BenSatori opened a new pull request, #3094:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/3094

   Dialects: Oracle, Generic
   
   `SELECT MAX(c.contact_name) KEEP (DENSE_RANK LAST ORDER BY c.id) AS metric 
FROM customers c` currently fails with:
   `Expected: end of statement, found: (`
   
   Oracle's FIRST/LAST aggregates take a `KEEP (DENSE_RANK { FIRST | LAST } 
ORDER BY ...)` clause after the function call, optionally followed by `OVER 
(...)`. This PR adds `Function::keep: Option<Box<KeepClause>>` (with 
`KeepClause` and `KeepRank`), parsed when 
`Dialect::supports_aggregate_keep_clause()` is true (Oracle and Generic). 
`KEEP` is only treated as the clause when followed by `(`, so `keep` stays 
usable as an identifier or alias.
   
   Syntax reference: 
https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/FIRST.html
   
   API change: `Function` gains a `keep` field, so code constructing `Function` 
literals needs `keep: None`.
   
   Note on stack usage: `Function` is the largest `Expr` variant, so this grows 
`Expr` from 328 to 336 bytes. On macOS arm64 debug builds that is enough to 
push `test_parentheses_overflow` (sqlparser_snowflake) and 
`parse_table_factor_paren_chain_no_exponential_blowup` (sqlparser_common) past 
the default 2 MiB test-thread stack; upstream main already passes them with 
only ~16-32 KiB to spare below the `recursive` crate's 128 KiB red zone. Any 
new field on `Function` would do the same. Opening as a draft to see how Linux 
CI behaves; happy to send a separate PR first (e.g. boxing `Function::over`) if 
you'd prefer.
   
   Fuzzed with `fuzz_parse_sql` and `fuzz_parse_roundtrip` for 60 seconds each, 
no panics. Seed: `fuzz/fuzz_seeds/oracle_aggregate_keep_clause.sql`.
   
   This PR was written with AI assistance (Claude Code). I reviewed every line 
and can explain each change.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


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