anew opened a new pull request, #57612:
URL: https://github.com/apache/spark/pull/57612

   ### What changes were proposed in this pull request?
     
   The `AUTO CDC` command previously required its clauses in a fixed order 
after `KEYS (...)`: `APPLY AS DELETE WHEN`, then `SEQUENCE BY`, then `COLUMNS`, 
then `STORED AS SCD TYPE`, then `TRACK HISTORY ON`. This relaxes the grammar so 
the optional clauses form an unordered set, accepted in any order.
     
   - **Grammar** (`SqlBaseParser.g4`): `autoCdcParameters` now matches the five 
clauses as a repeatable alternation `(autoCdcDeleteClause | 
autoCdcSequenceByClause | autoCdcColumnsClause | autoCdcStoredAsClause | 
autoCdcTrackHistoryClause)*` instead of a fixed positional sequence.
   - **`AstBuilder.parseAutoCdcParams`**: reads each clause from the resulting 
list; rejects a clause supplied more than once with `DUPLICATE_CLAUSES` via the 
shared `checkDuplicateClauses` helper; and enforces the still-mandatory 
`SEQUENCE BY` explicitly (the grammar no longer requires it positionally) with 
a targeted error.
     
   ### Why are the changes needed?
     
   As more AUTO CDC options are added, a fixed clause order is hard for users 
to remember. Allowing arbitrary ordering makes the syntax easier to use, 
consistent with how other Spark commands (e.g. `CREATE TABLE`) accept their 
optional clauses in any order.
   
   ### Does this PR introduce _any_ user-facing change?
     
   Yes, a SQL syntax relaxation.
   - Before: the AUTO CDC clauses had to be written in one fixed order; any 
other order failed with `PARSE_SYNTAX_ERROR`.
   - After: the optional clauses may be written in any order. Supplying the 
same clause twice now fails with `DUPLICATE_CLAUSES` ("Found duplicate clauses: 
<clauseName>."), and omitting the required `SEQUENCE BY` fails with a clear 
"AUTO CDC requires a SEQUENCE BY clause." message. Previously valid statements 
continue to parse unchanged.
     
   This is a relaxation within the unreleased AUTO CDC feature on master; no 
released behavior changes. 
     
   ### How was this patch tested?
     
   Updated `AutoCdcParserSuite` (67 tests, all passing):
     
   - The former "wrong clause order" negative tests are now positive tests 
asserting the clauses parse in the new orders, including one statement with a 
fully reversed clause order.
   - Added a duplicate-clause rejection test for each of the five clauses 
(asserting `DUPLICATE_CLAUSES`).
   - Updated the `SEQUENCE BY is required` tests to assert the new targeted 
error.
       
   ### Was this patch authored or co-authored using generative AI tooling?
     
   Generated-by: Claude Code (Opus 4.8)
   


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