Skip to content

[Iceberg CDC] Add watch for snapshots source#38834

Merged
ahmedabu98 merged 6 commits into
apache:masterfrom
ahmedabu98:iceberg_watchsdf
Jul 9, 2026
Merged

[Iceberg CDC] Add watch for snapshots source#38834
ahmedabu98 merged 6 commits into
apache:masterfrom
ahmedabu98:iceberg_watchsdf

Conversation

@ahmedabu98

Copy link
Copy Markdown
Contributor

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:

  • 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.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 WatchForSnapshotsSdf: Introduced a new SplittableDoFn that periodically polls an Iceberg table for new snapshots, tracking progress via monotonic sequence numbers.
  • Configuration Updates: Added maxSnapshotDiscoveryDelay to IcebergScanConfig to manage watermark advancement during idle periods.
  • Utility Refactoring: Updated ReadUtils and TableCache to expose necessary methods for snapshot discovery and table management.
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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist 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.

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.

Comment thread sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/TableCache.java Outdated
@github-actions

github-actions Bot commented Jun 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

@ahmedabu98

Copy link
Copy Markdown
Contributor Author

assign set of reviewers

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @chamikaramj for label java.

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).

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.73%. Comparing base (c531095) to head (9c8e798).
⚠️ Report is 87 commits behind head on master.

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     
Flag Coverage Δ
java 64.21% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Reminder, please take a look at this pr: @chamikaramj

@talatuyarer talatuyarer 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

if (fromSnapshot != null) {
fromSnapshot = table.snapshot(fromSnapshot).parentId();
Snapshot snapshot = table.snapshot(fromSnapshot);
fromSnapshot = snapshot != null ? snapshot.parentId() : null;

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.

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.

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.

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

@ahmedabu98

Copy link
Copy Markdown
Contributor Author

Will merge when tests go green

@ahmedabu98

Copy link
Copy Markdown
Contributor Author

IcebergIO Unit Test failures are irrelevant (see #39266)

@ahmedabu98
ahmedabu98 merged commit f8b0616 into apache:master Jul 9, 2026
21 of 24 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