Flink: Streaming from a missing branch can plan main's files and fail with a misleading error

Open
#19,154 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@jiwen624 is already working on this.

Since Nov 29, 2026.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java

Research direction

The issue identifies IcebergSource and the automatic starting strategies, but does not name source files or tests. Start by tracing how the source initializes a streaming position and discovers snapshots for a branch, then inspect tests for the listed strategies. Done means the chosen missing-branch behavior is explicit and avoids misleading planning failures or skipped files; the issue leaves that behavior undecided.

Written by the indexing model from the issue text.

Description

bug
Apache Iceberg version

None

Query engine

None

Please describe the bug 🐞

When IcebergSource streams from a branch that doesn't exist, the automatic starting strategies initialize the position from main, but later discovery looks up the branch and finds no snapshot. If the saved position is non-null, planning throws Invalid last enumerated position for an empty table: not null, which doesn't mention the branch, and the job fails once max-allowed-planning-failures (default 3) is exceeded.

  • TABLE_SCAN_THEN_INCREMENTAL: plans main's files, so rows from main may be emitted before the failure.
  • INCREMENTAL_FROM_LATEST_SNAPSHOT_EXCLUSIVE: fails whenever main has a current snapshot.
  • INCREMENTAL_FROM_LATEST_SNAPSHOT, INCREMENTAL_FROM_EARLIEST_SNAPSHOT: fail if the chosen start snapshot has a parent ID (e.g. main has 2+ snapshots, or older snapshots were expired). Otherwise they wait.

When the table has no current snapshot, these strategies wait and read the branch once it's created, so failing fast would change existing behavior. Simply treating a missing branch as empty doesn't work either: TABLE_SCAN_THEN_INCREMENTAL then skips its initial scan once the branch appears and misses still-live files from expired snapshots. Waiting would need the source to stay uninitialized until the branch exists.

Should a missing branch fail, or wait for the branch to be created? A clearer error naming the branch would help either way. Found while working on #19099, which keeps this behavior unchanged.

Willingness to contribute
  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time
Dominant language
Java
Stars
9.5k
Forks
3.7k
Avg merge
2d 2h
Merged PRs (30d)
170

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/iceberg

All issues in apache/iceberg

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.