Skip to content

AddFiles: Wire a destination-table key through the registration chain - #40817

Merged
claudevdm merged 4 commits into
apache:masterfrom
claudevdm:addfiles-dynamic-dest3
Oct 27, 2026
Merged

claudevdm merged 4 commits into
apache:masterfrom
claudevdm:addfiles-dynamic-dest3

Conversation

@claudevdm

Copy link
Copy Markdown
Collaborator

Threads a destination-table key through the AddFiles registration chain, holding the key
constant at the configured table.

stage before after
ReadFooterSchema DoFn<String, SchemaGroup> DoFn<KV<String,String>, KV<String,SchemaGroup>>
ConvertToDataFile DoFn<String, SerializableDataFile> DoFn<KV<String,String>, KV<String,SerializableDataFile>>
CreateManifests keyed by specId keyed by KV<table, specId>
CommitManifestFilesDoFn identifier field batch.getKey()

AddFiles.expand supplies the constant with
WithKeys.<String,String>of(tableIdentifier), and distinctSchemas drops the key again so
its global combine and the commit path downstream are untouched.

Reviewable as six steps, in this order:

  1. key the footer read, add the fileSchemas helper
  2. key its two test helpers
  3. the converter's cached table becomes a ConcurrentMap<String, TableState>, name still constant
  4. key the converter; identifier and its constructor parameters are deleted
  5. the manifest key becomes KV<table, specId>
  6. the committer reads its table from the key

@github-actions github-actions Bot added java io iceberg Iceberg IO connector size/xl XL: >=1000 lines changed labels Oct 26, 2026
@claudevdm
claudevdm force-pushed the addfiles-dynamic-dest3 branch from cea3aea to 782c0c4 Compare October 27, 2026 01:40
@github-actions github-actions Bot added size/m M: 50-249 lines changed and removed size/xl XL: >=1000 lines changed labels Oct 27, 2026
@claudevdm
claudevdm marked this pull request as ready for review October 27, 2026 01:45
@claudevdm
claudevdm requested a review from ahmedabu98 October 27, 2026 01:45
@claudevdm

Copy link
Copy Markdown
Collaborator Author

R: @ahmedabu98

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📋 Review Summary

This PR cleanly threads a destination-table key (String) through the AddFiles registration pipeline (ReadFooterSchema, ConvertToDataFile, CreateManifests, and CommitManifestFilesDoFn) in preparation for dynamic table destinations. The refactoring preserves existing single-table behavior by attaching a constant table key via WithKeys and dropping it before the global schema combination step.

🔍 General Feedback

  • Thread-safety in ConvertToDataFile is well-maintained by transitioning the single-table state fields into a per-table TableState object managed in a ConcurrentMap, with synchronization and refresh flags scoped per table.
  • Coders and key types are properly configured across all modified PCollection stages and unit test helpers.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@github-actions

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@ahmedabu98 ahmedabu98 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, just a couple suggestions

}

PCollection<KV<Integer, SerializableDataFile>> keyedFiles =
PCollection<KV<KV<String, Integer>, SerializableDataFile>> keyedFiles =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This breaks update and upgrade compatibility right?
I think it might be unavoidable, but please mention it in CHANGES.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: for this and below, can we use an Autovalue/Row type (containing destination and specID) instead of KV<String, Integer>?

Will make it more readable and also give us flexibility to add more columns in the future without breaking update compatibility

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure will mention in CHANGES.md, but I don't think breaking update compat is a big deal for AddFiles. It is a temporary migration transform that is highly unlikely to be updated in place.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We're turning it into a Managed transform (#40827) so will also need to be wary of upgrade incompatible changes (e.g. a graph change from 2.77 to upgraded 2.79)

The current multi-table changes should be fine though, since Managed transform will come in 2.78 too

@claudevdm
claudevdm merged commit 728ef1b into apache:master Oct 27, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

iceberg Iceberg IO connector io java Next Action: Reviewers size/m M: 50-249 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants