Skip to content

[SPARK-59183][SDP] SCD2 Ignore-null support; Populate version map per event row at ingest - #58645

Draft
AnishMahto wants to merge 16 commits into
apache:masterfrom
AnishMahto:SPARK-59183-populate-verison-map-at-ingest
Draft

[SPARK-59183][SDP] SCD2 Ignore-null support; Populate version map per event row at ingest#58645
AnishMahto wants to merge 16 commits into
apache:masterfrom
AnishMahto:SPARK-59183-populate-verison-map-at-ingest

Conversation

@AnishMahto

Copy link
Copy Markdown
Contributor

This is a stacked PR. See incremental diff here: AnishMahto/spark@SPARK-59208-introduce-ignore-null-change-arg...SPARK-59183-populate-verison-map-at-ingest

See previous PR in stack here: #58505

What changes were proposed in this pull request?

When processing an incoming microbatch, if ignore-null is enabled for the AutoCDC flow, a non-null version map needs to be populated for every row in the microbatch.

As per the version map contract (see Scd2VersionMap's scaladoc), the version map is populated with null-authorship information for every event, respecting the currently active ignore-null selection.

This ticket is not concerned with reconciling the microbatch's version maps with existing rows in the aux/target table.

Why are the changes needed?

Core part of the algorithm for supporting ignore-null API in SCD2.

Does this PR introduce any user-facing change?

No. The user facing interfaces for ignore-null are not exposed yet, this logic cannot be hit yet.

How was this patch tested?

Unit tests.

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

Co-authored with GPT-5.6 Sol.

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