[SPARK-58319][SDP] Derive SCD2 AutoCDC target table schema#57496
Open
anew wants to merge 1 commit into
Open
Conversation
Implement the ScdType.Type2 branch of AutoCdcMergeFlow.schema and load in Flow.scala, which previously threw AUTOCDC_SCD2_NOT_SUPPORTED. The SCD2 target schema is the user-selected columns followed by the SCD2 framework columns, in the exact order and nullability that Scd2BatchProcessor.preprocessMicrobatch projects and the merges persist: __START_AT and __END_AT (typed as the sequencing type, nullable), then the operational _cdc_metadata struct (non-null). To build this from the graph package, widen the visibility of Scd2BatchProcessor.startAtColName / endAtColName (private[autocdc] -> private[pipelines]) and constructCdcMetadataCol (private -> private[pipelines]). SCD2 AutoCDC flows are now constructible (their schema resolves) but still cannot run: the auxiliary-table derivation (AutoCdcAuxiliaryTable) and the flow planner (FlowPlanner) still reject SCD2. Those gates, and end-to-end wiring, are removed in follow-up subtasks under SPARK-56249. Adds tests in AutoCdcFlowSuite and replaces the obsolete "rejects SCD2 at construction" test. Co-authored-by: Isaac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: [SPARK-58319][SDP] Derive SCD2 AutoCDC target table schema
Body:
What changes were proposed in this pull request?
Implement the
ScdType.Type2branch ofAutoCdcMergeFlow.schemaandloadinFlow.scala, which previously threwAUTOCDC_SCD2_NOT_SUPPORTED. The SCD2 target schema is the user-selected columns followed by the SCD2 framework columns, in the exact order and nullability thatScd2BatchProcessor.preprocessMicrobatchprojects and the merges persist:__START_AT(typed as the sequencing type, nullable)__END_AT(typed as the sequencing type, nullable)_cdc_metadata(the SCD2 operational metadata struct, non-null)To build this from the
graphpackage, the visibility of a fewScd2BatchProcessormembers is widened:startAtColName/endAtColName(private[autocdc]->private[pipelines]) andconstructCdcMetadataCol(private->private[pipelines]).cdcMetadataColSchemawas alreadyprivate[pipelines].This is one subtask of enabling SCD2 AutoCDC end to end (under SPARK-56249). After this change, SCD2 AutoCDC flows are constructible (their output schema resolves), but they still cannot run: the auxiliary-table derivation (
AutoCdcAuxiliaryTable) and the flow planner (FlowPlanner) still reject SCD2. Those remaining gates and the streaming-write wiring are handled in follow-up subtasks (SPARK-58320, SPARK-58321).Why are the changes needed?
Deriving the SCD2 target schema is a prerequisite for SCD2 support: the pipeline's downstream dataset materialization and schema evolution consume
AutoCdcMergeFlow.schema, so an SCD2 flow cannot be registered or its target table created until this branch produces the correct augmented schema. TheScd2BatchProcessorreconciliation engine that produces rows in this exact shape already landed (SPARK-57378); this connects the flow's declared schema to it.Does this PR introduce any user-facing change?
No. SCD2 AutoCDC flows remain unusable end to end (still gated by the auxiliary-table and planner checks), so there is no change to released or user-facing behavior. This only makes the flow's schema resolvable internally.
How was this patch tested?
New unit tests in
AutoCdcFlowSuite(replacing the obsolete "rejects SCD2 at construction" test):schemaappends the SCD2 framework columns in the correct order/nullability when no column selection is set;columnSelectionnarrows only the user-data portion, before the framework columns;load()'s empty-dataframe schema matchesschemafor SCD2.Was this patch authored or co-authored using generative AI tooling?
Generated-By: Claude Opus 4.8