Skip to content

[core][rest] Add branch merge support for append-only tables#7882

Open
JunRuiLee wants to merge 2 commits into
apache:masterfrom
JunRuiLee:branch_merge_final2_part1
Open

[core][rest] Add branch merge support for append-only tables#7882
JunRuiLee wants to merge 2 commits into
apache:masterfrom
JunRuiLee:branch_merge_final2_part1

Conversation

@JunRuiLee
Copy link
Copy Markdown
Contributor

Purpose

This PR is the first part of #7863, focusing on the core APIs, implementation, and REST support for branch merge.

It adds mergeBranch, which incrementally adds data files that exist only in the source branch to the target branch, without replacing either branch. Correctness is guarded by the immutable table option 'branch-merge.enabled' = 'true', which enforces the pure-append invariant required by file-level branch merge: compaction and INSERT OVERWRITE are rejected, and deletion vectors are not supported.

Tests

Added core tests:

  • AppendOnlySimpleTableTest#testMergeBranch
  • AppendOnlySimpleTableTest#testMergeBranchMultipleTimes
  • AppendOnlySimpleTableTest#testMergeBranchFailsOnStaleDuplicateCommit
  • AppendOnlySimpleTableTest#testMergeBranchBidirectional
  • AppendOnlySimpleTableTest#testMergeBranchEmptyDiff
  • AppendOnlySimpleTableTest#testMergeBranchSchemaConflict
  • AppendOnlySimpleTableTest#testMergeBranchSchemaHistoryConflict
  • AppendOnlySimpleTableTest#testMergeBranchRowTrackingTable
  • AppendOnlySimpleTableTest#testMergeBranchRowTrackingMultipleTimes
  • AppendOnlySimpleTableTest#testMergeBranchRowTrackingAfterTargetWrites
  • AppendOnlySimpleTableTest#testMergeBranchRowTrackingBetweenNonMainBranches
  • AppendOnlySimpleTableTest#testMergeBranchRowTrackingMismatch
  • AppendOnlySimpleTableTest#testMergeBranchRowTrackingStaleMerge
  • AppendOnlySimpleTableTest#testMergeBranchSameBranch
  • AppendOnlySimpleTableTest#testMergeBranchSamePartition
  • AppendOnlySimpleTableTest#testMergeBranchNonExistentBranch
  • AppendOnlySimpleTableTest#testMergeBranchMultiBucket
  • AppendOnlySimpleTableTest#testMergeBranchNonExistentTargetBranch
  • AppendOnlySimpleTableTest#testMergeBranchBetweenNonMainBranches
  • AppendOnlySimpleTableTest#testMergeBranchWithoutBranchMergeEnabled
  • AppendOnlySimpleTableTest#testMergeBranchAfterSnapshotExpiration
  • AppendOnlySimpleTableTest#testBranchMergeEnabledRejectsOverwrite
  • PrimaryKeySimpleTableTest#testMergeBranchPrimaryKeyTable

Added REST tests:

  • RESTCatalogTest#testMergeBranch
  • branch-not-exist coverage in RESTCatalogTest#testBranches

JunRuiLee added 2 commits May 17, 2026 12:03
Add mergeBranch(sourceBranch, targetBranch) to Table and Catalog
interfaces, with default/delegate implementations.

Add branch-merge.enabled @immutable table option to CoreOptions.
When enabled, the table is restricted to pure-append commits only,
guaranteeing that branch merge is always safe.

Add BranchMergeHandler interface and extend BranchManager with
mergeBranch() and merge validation utilities.
Implement FileSystemBranchManager.mergeBranch() with:
- Symmetric branch-merge.enabled validation on both branches
- Append-only table validation (no primary keys)
- Row-tracking consistency check between branches
- Schema compatibility validation (fields and schema history)
- Active-file diff to find branch-only files
- DefaultBranchMergeHandler for committing merged files

Enforce pure-append invariant when branch-merge.enabled=true:
- SchemaValidation rejects primary keys, deletion vectors, and
  data evolution at table creation time
- FileStoreCommitImpl rejects compaction and INSERT OVERWRITE
  at commit time

Add Catalog and REST API support (CatalogBranchManager, RESTCatalog,
POST /branches/merge endpoint).

Add comprehensive tests covering positive merge, row-tracking,
snapshot expiration, schema conflicts, and negative cases.

Add branch merge documentation and REST OpenAPI spec.
@JunRuiLee JunRuiLee force-pushed the branch_merge_final2_part1 branch from 616f113 to 1a55a59 Compare May 18, 2026 04:04
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.

1 participant