[Spark] Align DSv2 _metadata with Spark base fields + row tracking#6775
Open
murali-db wants to merge 2 commits into
Open
[Spark] Align DSv2 _metadata with Spark base fields + row tracking#6775murali-db wants to merge 2 commits into
murali-db wants to merge 2 commits into
Conversation
- Align DSv2 Kernel SparkTable.metadataColumns() with Spark file-source base metadata (file_path, file_name, file_size, file_block_start, file_block_length, file_modification_time). When row tracking is enabled, append row_id and row_commit_version after the base fields. - Materialise _metadata via a per-field setter strategy. One MetadataValueSetterBuilder per requested struct field, bound to file-level constants once per PartitionedFile, run per row by MetadataStructReadFunction. - Three setter implementations: FileConstantValueSetterBuilder (wraps DeltaParquetFileFormat#fileConstantMetadataExtractors), RowIdValueSetterBuilder and RowCommitVersionValueSetterBuilder (encapsulate the coalesce against materialised helper columns). - MetadataStructSchemaContext.forSchema(...) returns Optional, built only when the scan requests _metadata. - Replaces the previous RowTrackingReadFunction / RowTrackingSchemaContext design; row tracking is now modelled as two specialised _metadata fields. - Adds parametrised tests covering each base subfield and the row-tracking coalesce paths.
Reformat 14 Java sources to match Delta OSS google-java-format conventions.
d1ef3a1 to
34ac2a4
Compare
SanJSp
approved these changes
May 15, 2026
Collaborator
SanJSp
left a comment
There was a problem hiding this comment.
Thanks for the changes - nothing to remark from my side!
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.
What changes were proposed in this pull request?
Align the DSv2 Kernel
SparkTable.metadataColumns()with Spark file-source base metadata, and unify the per-row materialisation path for both file-source and row-tracking fields.SparkTable.metadataColumns()returns a single_metadatastruct containing Spark'sBASE_METADATA_FIELDS(file_path,file_name,file_size,file_block_start,file_block_length,file_modification_time); when row tracking is enabled,row_idandrow_commit_versionare appended._metadatavia a per-field setter strategy. OneMetadataValueSetterBuilderis registered per requested struct field;MetadataStructReadFunctionbinds each builder to the currentPartitionedFileonce and runs the resultingBoundMetadataValueSetters per row, writing into a reusedGenericInternalRow(no per-rowObject[]copy).FileConstantValueSetterBuilder— wraps the extractors exposed byDeltaParquetFileFormat#fileConstantMetadataExtractors(Spark base fields plus Delta extras likebase_row_id/default_row_commit_version).RowIdValueSetterBuilder/RowCommitVersionValueSetterBuilder— encapsulate the Delta coalesce against materialised row-tracking helper columns, falling back tobaseRowId + physicalRowIndex/default_row_commit_versionrespectively.MetadataStructSchemaContext.forSchema(...)is the single owner of the pruned_metadatastruct, the parquet read schema (augmented with row-tracking helper columns when needed), data / partition projection ordinals, and the orderedMetadataValueSetterBuilder[]. ReturnsOptionalso it's only constructed when the scan requests_metadata.RowTrackingReadFunction/RowTrackingSchemaContextdesign; row tracking is now modelled as two specialised_metadatafields, keeping per-field plumbing uniform.How was this patch tested?
V2MetadataReadTestcovering single-subfield projection (parametrised across the six base fields), bare_metadatastruct selection,SELECT _metadata, *, and mixedfile_path+ row-tracking projection.V2RowTrackingReadTest.testMixedFileHistoryRowIdResolvesexercises both branches of the row-id coalesce against a table with mixed file history (INSERT, UPDATE rewrite, INSERT).MetadataStructSchemaContextTest,MetadataValueSetterTest,MetadataStructReadFunctionTestcovering the schema-context, individual setter builders, and end-to-end read-function wiring.SparkTableTestwith metadata-column assertions for both row-tracking-enabled and disabled tables.Does this PR introduce any user-facing change?
_metadataon the DSv2 Delta connector is a wider struct than before. Name-based access (_metadata.row_id,_metadata.file_path, etc.) stays stable. Positional access against the previous shape may break — callers should switch to name-based access.