Skip to content

Spark 4.2: Create branch and tag from the selected ref in ALTER TABLE - #19150

Open
Amineharrabi wants to merge 1 commit into
apache:mainfrom
Amineharrabi:spark-create-ref-from-selected-branch
Open

Amineharrabi wants to merge 1 commit into
apache:mainfrom
Amineharrabi:spark-create-ref-from-selected-branch

Conversation

@Amineharrabi

@Amineharrabi Amineharrabi commented Nov 26, 2026 •

Copy link
Copy Markdown

ALTER TABLE t.branch_work CREATE BRANCH child (and CREATE TAG) accepted the branch selector but created the ref from the head of main, because CreateOrReplaceBranchExec and CreateOrReplaceTagExec read table.currentSnapshot(). They now use the snapshot of the SparkTable the identifier resolves to, so the ref starts from work's head, matching how reads and writes through t.branch_work behave. Without a selector this is still main's head, and AS OF VERSION still takes precedence. Spark 3.5, 4.0 and 4.1 have the same code and can follow in a backport once this is reviewed.

Fixes #19141

Test plan: TestBranchDDL.createBranchFromSelectedBranch and TestTagDDL.createTagFromSelectedBranch advance main past a branch work, create a ref through t.branch_work, and check that it points at work's head; both fail without the change. The existing TestBranchDDL, TestTagDDL and TestReplaceBranch tests pass.


AI Disclosure
AI was used with human oversight

ALTER TABLE t.branch_x CREATE BRANCH/TAG accepted the branch selector
but created the new ref from the head of main. The new ref now starts
from the snapshot of the table as the identifier selects it, which is
main's head when there is no selector.

Generated-by: Claude Code
@github-actions github-actions Bot added the spark label Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ALTER TABLE t.branch_x CREATE BRANCH/TAG creates the ref from main

1 participant