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

   ### What changes were proposed in this pull request?
   
   Expose Auto CDC SCD Type 2 through the Python and Spark Connect APIs. 
`create_auto_cdc_flow` now accepts `stored_as_scd_type=2` (or `"2"`) and the 
SCD2-only `track_history_column_list` / `track_history_except_column_list` 
parameters, which flow through to `ChangeArgs(storedAsScdType = Type2, 
trackHistorySelection = ...)` on the server.
   
   Specifically:
   - Proto: add `SCD_TYPE_2` to the `SCDType` enum and 
`track_history_column_list` (field 11) / `track_history_except_column_list` 
(field 12) to `AutoCdcFlowDetails`. Field numbers match the Databricks runtime 
extension proto for wire compatibility. Regenerate the Python stubs.
   - Python API (`api.py`, `flow.py`): widen `stored_as_scd_type`, add and 
normalize the track-history parameters, and reject track-history columns unless 
SCD2 is selected.
   - Serialization (`spark_connect_graph_element_registry.py`): map the SCD 
type and serialize the track-history columns.
   - Server (`PipelinesHandler.scala`): map `SCD_TYPE_2` to `ScdType.Type2`, 
build `trackHistorySelection`, and reject specifying both track-history lists.
   - Add error condition 
`AUTOCDC_BOTH_TRACK_HISTORY_COLUMN_LIST_AND_EXCEPT_COLUMN_LIST`.
   
   The engine's SCD2 execution path is landing in a parallel workstream and 
still rejects SCD2 during graph analysis (`AUTOCDC_SCD2_NOT_SUPPORTED`). This 
change wires the API to the `ChangeArgs` contract those changes plug into; 
end-to-end SCD2 execution starts working once the engine drops those throws, 
with no further API change required.
   
   ### Why are the changes needed?
   
   The Python and Spark Connect Auto CDC APIs previously only supported SCD 
Type 1. SCD Type 2 (history tracking) is a common CDC requirement and is 
already modeled in the engine's `ChangeArgs`/`ScdType`.
   
   ### Does this PR introduce any user-facing change?
   
   Yes. `create_auto_cdc_flow` accepts `stored_as_scd_type=2` and the 
`track_history_column_list` / `track_history_except_column_list` parameters.
   
   ### How was this patch tested?
   
   New unit tests in `test_auto_cdc_flow.py` (SCD2 accept as int/str, 
track-history include/exclude, track-history-requires-SCD2 rejection) and 
`PythonPipelineSuite.scala` (SCD2 registration forwards to `ChangeArgs`, 
both-lists rejection). Ran the Python and Scala suites plus ruff/mypy.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   Generated-by: 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