Skip to content

Spark 4.0: Row Lineage support #13310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

amogh-jahagirdar
Copy link
Contributor

This change implements spark 4.0 with Iceberg v3's row lineage feature; this approach uses the new conditional nullification mechanism introduced in 4.0 instead of custom rules that we implemented for 3.5

@github-actions github-actions bot added the spark label Jun 14, 2025
Comment on lines +719 to +731
protected InternalRow lineageRow(InternalRow meta) {
GenericInternalRow row = new GenericInternalRow(2);
row.setNullAt(0);
row.setNullAt(1);

if (meta == null) {
return row;
}

// Ordinals are cached
if (rowIdOrdinal != null && lastUpdatedOrdinal != null) {
setIfNotNull(row, 0, meta, rowIdOrdinal);
setIfNotNull(row, 1, meta, lastUpdatedOrdinal);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll ideally need to figure out a shared abstraction for both the MoR DeltaWriter impl and CoW so we can share the logic to derive the metadata values instead of duplicating the logic

Comment on lines +128 to +134
if (writeIncludesRowLineage) {
sparkWriteSchema = sparkWriteSchema.add("_row_id", LongType$.MODULE$);
sparkWriteSchema =
sparkWriteSchema.add(
MetadataColumns.LAST_UPDATED_SEQUENCE_NUMBER.name(), LongType$.MODULE$);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate helper method updateSparkWriteSchemaWithLineage would make it clearer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant