Skip to content

[Iceberg CDC sink] Write deltas transform - #40031

Merged
ahmedabu98 merged 8 commits into
apache:masterfrom
ahmedabu98:cdc-write-deltas
Sep 17, 2026
Merged

ahmedabu98 merged 8 commits into
apache:masterfrom
ahmedabu98:cdc-write-deltas

Conversation

@ahmedabu98

@ahmedabu98 ahmedabu98 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Adds the CDC sink's write stage: WriteDeltas runs the delta writer over each sorted (destination, shard, window) group under the worker's pinned partition spec.

Outputs ShardDeltaFiles, carrying the resulting data and equality-delete files, with their sequence range, to the committer.

Part of #39979


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@github-actions github-actions Bot added the iceberg Iceberg IO connector label Sep 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @kennknowles for label java.
R: @chamikaramj for label iceberg.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

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

Thanks!

"WriteDeltas",
ParDo.of(
new WriteDeltasFn(
new TableSetup(catalogConfig, config, destinations, filePrefix),

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.

Specifying a filePrefix as to the runId param can be error prone ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe filePrefix isn't the best naming. It's just an ID that is generated once per pipeline launch. I'll rename it to runId if that helps

dataFormat,
deleteFormat);

org.apache.iceberg.Schema tableSchema = table.schema();

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.

There are multiple table.schema() invocations here and within RecordDeltaTaskWriter.create. Probably do the invocation once and pass it for consistency ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We're using the same table instance for these calls so it should be consistent throughout? Not sure if I'm understanding the comment correctly

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.

Can the underlying table from TableCache refresh ? If not yeah, it's mostly a readability issue. Up to you.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah good catch, we can have different table.schema() results if another thread refreshes the cache in the middle (although it's a very very tiny window).
The issue though is that inside the writer, we're using Iceberg's writerFactory which is initialized using GenericFileWriterFactory.Builder(table) and itself calls table.schema() internally.

I fixed it by creating a SerializableTable copy of the table so that the metadata version is constant throughout the process call

@ahmedabu98

Copy link
Copy Markdown
Contributor Author

Thanks @chamikaramj, can you PTAL ?

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

Thanks!

dataFormat,
deleteFormat);

org.apache.iceberg.Schema tableSchema = table.schema();

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.

Can the underlying table from TableCache refresh ? If not yeah, it's mostly a readability issue. Up to you.

@ahmedabu98
ahmedabu98 merged commit 57801c9 into apache:master Sep 17, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants