Skip to content

[core] Fix main table's CatalogEnvironment used when switching branch on fallback table#7878

Merged
JingsongLi merged 4 commits into
apache:masterfrom
XiaoHongbo-Hope:branch_fix
May 18, 2026
Merged

[core] Fix main table's CatalogEnvironment used when switching branch on fallback table#7878
JingsongLi merged 4 commits into
apache:masterfrom
XiaoHongbo-Hope:branch_fix

Conversation

@XiaoHongbo-Hope
Copy link
Copy Markdown
Contributor

@XiaoHongbo-Hope XiaoHongbo-Hope commented May 17, 2026

Purpose

When a table has scan.fallback-branch or scan.primary-branch set, switchToBranch() passed the main
table's CatalogEnvironment to the branch table. This caused REST snapshot loading to query the main
table instead of the branch, returning the wrong snapshot ID.

Fix: copy the CatalogEnvironment with a branch-aware Identifier.

Tests

FallbackReadFileStoreTableTest.testSwitchToBranch

XiaoHongbo-Hope and others added 3 commits May 16, 2026 22:23
…t regression)

When a REST catalog returns the main table's snapshot for a branch query,
SnapshotManager.latestSnapshotId() returns the wrong snapshot ID. This causes
a mismatch between latestSnapshotId() (from REST) and safelyGetAllSnapshots()
(from filesystem), which is the root cause of the Frankfurt eu-central-1
"safelyGetAllSnapshots did not include latest snapshot" error on tables with
branches.

The test verifies:
1. The mismatch when a buggy REST loader returns the main table's snapshot
2. No mismatch when the loader correctly returns the branch's snapshot
3. copyWithBranch correctly propagates the loader

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…logEnvironment

When a table has scan.fallback-branch or scan.primary-branch set, getTable()
returns a FallbackReadFileStoreTable. Calling switchToBranch() on it delegates
to switchWrappedToBranch(), which previously passed the main table's
CatalogEnvironment to the branch table. This caused REST snapshot loading
(via SnapshotLoader) to query the main table's endpoint instead of the
branch's (e.g. tableName$branch_branchName), returning the wrong snapshot ID.

Fix: create a branch-aware CatalogEnvironment by copying the wrapped table's
environment with an Identifier that includes the branch name.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@XiaoHongbo-Hope XiaoHongbo-Hope changed the title [core] Fix main table's snapshot returned when switching branch on table with fallback/primary branch [core] Fix main table's CatalogEnvironment used when switching branch on fallback table May 17, 2026
Copy link
Copy Markdown
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

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

+1

@JingsongLi JingsongLi merged commit 58b8c61 into apache:master May 18, 2026
12 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants