Skip to content

[SPARK-59208][SDP] SCD2 Ignore-null support; Introduce ignore-null selection in ChangeArgs - #58505

Draft
AnishMahto wants to merge 12 commits into
apache:masterfrom
AnishMahto:SPARK-59208-introduce-ignore-null-change-arg
Draft

[SPARK-59208][SDP] SCD2 Ignore-null support; Introduce ignore-null selection in ChangeArgs#58505
AnishMahto wants to merge 12 commits into
apache:masterfrom
AnishMahto:SPARK-59208-introduce-ignore-null-change-arg

Conversation

@AnishMahto

Copy link
Copy Markdown
Contributor

This is a stacked PR. See incremental diff here: AnishMahto/spark@SPARK-59165-scd2-version-map-schema...SPARK-59208-introduce-ignore-null-change-arg

What changes were proposed in this pull request?

ChangeArgs holds all of the user-specified configurations (arguments) that should apply to their AutoCDC flow by execution time.

Ignore-null is a new AutoCDC argument that allows users to specify a set of columns that AutoCDC should treat as unauthored by an event when they receive a null-value in that event.

We need to represent this selection in ChangeArgs so that AutoCDC batch processors can later reference it, and validate that the columns selected indeed exist and are eligible for selection. Ex. a key column or reserved AutoCDC column may never be specified as ignore-null.

Why are the changes needed?

To support the ignore-null feature for AutoCDC SCD2 (as per the approved SPIP), we need to represent the user-specified ignore null column selection during pipeline analysis and execution.

Does this PR introduce any user-facing change?

No. We introduce internal plumbing and representation for ignore-null selection, but no user-facing API exists yet to specify the ignore-null selection.

How was this patch tested?

Unit tests.

Was this patch authored or co-authored using generative AI tooling?

Co-authored with Claude Opus 4.6

diffSchemas previously compared top-level fields only. When a struct
column gained or lost nested fields, the entire column type was emitted
as an UpdateColumnType -- a change many DSv2 connectors reject because
the semantics of replacing a whole struct type are ambiguous.

This patch makes diffSchemas recurse into StructType columns: nested
field additions become addColumn with multi-part field paths, deletions
become deleteColumn, and type/nullability changes become the
corresponding nested updateColumnType/updateColumnNullability. This is
the DSv2-idiomatic way to evolve struct columns and is supported by
Delta, Iceberg, and other connectors that handle nested schemas.
Add a nullable __VERSION_MAP field (Map<String, Boolean>) to the SCD2
_cdc_metadata struct. This field will track per-column authorship for
ignore-null semantics in a future change; for now it is always null.

Source changes:
- Introduce Scd2VersionMap with mapType and authorship contract docs.
- Add versionMapFieldName, versionMapOf to Scd2BatchProcessor companion.
- Extend cdcMetadataColSchema and constructCdcMetadataCol with the new
  field. All four call sites pass versionMap explicitly (no default).
- Decomposition tails and tombstones always receive a null version map
  (synthetic rows carry no authorship claim).

Test changes:
- Update all Row(...) constructions for CDC metadata structs across
  Scd2BatchProcessorSuite, Scd2BatchProcessorMergeSuite,
  Scd2ForeachBatchHandlerSuite, and 7 graph execution test suites.
- Fix schema-preservation tests to use the production two-field
  cdcMetadataInnerSchema.
- Update scd2MetadataDdl in AutoCdcGraphExecutionTestMixin.
@AnishMahto
AnishMahto force-pushed the SPARK-59208-introduce-ignore-null-change-arg branch from 0957bfd to 773c8aa Compare September 4, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant