[Iceberg CDC] Add watch for snapshots source#38834
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request implements a snapshot-watching mechanism for Iceberg CDC in Apache Beam. By periodically polling for new snapshots and tracking them using monotonic sequence numbers, the system can effectively stream changes from an Iceberg table. It includes robust handling for watermark advancement during idle periods and provides comprehensive unit testing for the new SDF logic. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces WatchForSnapshotsSdf, a SplittableDoFn that monitors Iceberg tables for new snapshots, alongside necessary visibility and configuration updates in IcebergScanConfig, ReadUtils, and TableCache. The review feedback identifies several critical issues: a potential NullPointerException in ReadUtils when resolving expired snapshots, stale metadata returns in TableCache due to asynchronous cache refreshing, incorrect range estimation and stale cache usage in WatchForSnapshotsSdf, and a missing validation check to enforce Iceberg table format version 2 or higher for CDC scans.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
|
assign set of reviewers |
|
Assigning reviewers: R: @chamikaramj for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #38834 +/- ##
=========================================
Coverage 57.73% 57.73%
- Complexity 13049 13052 +3
=========================================
Files 2513 2513
Lines 261615 261618 +3
Branches 10745 10746 +1
=========================================
+ Hits 151035 151048 +13
+ Misses 104846 104837 -9
+ Partials 5734 5733 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Reminder, please take a look at this pr: @chamikaramj |
| if (fromSnapshot != null) { | ||
| fromSnapshot = table.snapshot(fromSnapshot).parentId(); | ||
| Snapshot snapshot = table.snapshot(fromSnapshot); | ||
| fromSnapshot = snapshot != null ? snapshot.parentId() : null; |
There was a problem hiding this comment.
What happen if A user's from_snapshot is expired by table maintenance before a pipeline restart IncrementalScanSource ? I believe the existing WatchForSnapshots silently reprocess the entire table history, it will emit mass duplicates with no warning.
There was a problem hiding this comment.
This PR's watch transform keeps track of the snapshot sequence number (stateful), so on restart it should skip everything up to the last processed snapshot
|
Will merge when tests go green |
|
IcebergIO Unit Test failures are irrelevant (see #39266) |
Adds a source that periodically polls for snapshots and outputs the snapshot ID. Tracks progress based on snapshot sequence number, which is monotonically increasing unlike the ID.
Part of #38831
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
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, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.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)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.