diff --git a/paimon-core/src/main/java/org/apache/paimon/utils/FileSystemBranchManager.java b/paimon-core/src/main/java/org/apache/paimon/utils/FileSystemBranchManager.java index 3257ea10603c..9c09637d1c37 100644 --- a/paimon-core/src/main/java/org/apache/paimon/utils/FileSystemBranchManager.java +++ b/paimon-core/src/main/java/org/apache/paimon/utils/FileSystemBranchManager.java @@ -195,10 +195,11 @@ public void fastForward(String branchName) { schemaManager.copyWithBranch(branchName).schemaDirectory(), schemaManager.schemaDirectory(), true); - fileIO.copyFiles( - tagManager.copyWithBranch(branchName).tagDirectory(), - tagManager.tagDirectory(), - true); + // Continue fast-forward even without tags. + Path branchTagDirectory = tagManager.copyWithBranch(branchName).tagDirectory(); + if (fileIO.exists(branchTagDirectory)) { + fileIO.copyFiles(branchTagDirectory, tagManager.tagDirectory(), true); + } snapshotManager.invalidateCache(); } catch (IOException e) { throw new RuntimeException( diff --git a/paimon-core/src/test/java/org/apache/paimon/table/SimpleTableTestBase.java b/paimon-core/src/test/java/org/apache/paimon/table/SimpleTableTestBase.java index 7681443b143e..cfdccc197ec3 100644 --- a/paimon-core/src/test/java/org/apache/paimon/table/SimpleTableTestBase.java +++ b/paimon-core/src/test/java/org/apache/paimon/table/SimpleTableTestBase.java @@ -1356,6 +1356,35 @@ public void testFastForward() throws Exception { "4|40|400|binary|varbinary|mapKey:mapVal|multiset"); } + @Test + public void testFastForwardWithoutTag() throws Exception { + FileStoreTable table = createFileStoreTable(); + + try (StreamTableWrite write = table.newWrite(commitUser); + StreamTableCommit commit = table.newCommit(commitUser)) { + write.write(rowData(0, 0, 0L)); + commit.commit(0, write.prepareCommit(false, 1)); + } + + table.createBranch(BRANCH_NAME); + FileStoreTable tableBranch = createBranchTable(BRANCH_NAME); + + try (StreamTableWrite write = tableBranch.newWrite(commitUser); + StreamTableCommit commit = tableBranch.newCommit(commitUser)) { + write.write(rowData(2, 20, 200L)); + commit.commit(1, write.prepareCommit(false, 2)); + } + + table.fastForward(BRANCH_NAME); + + assertThat( + getResult( + table.newRead(), + toSplits(table.newSnapshotReader().read().dataSplits()), + BATCH_ROW_TO_STRING)) + .contains("2|20|200|binary|varbinary|mapKey:mapVal|multiset"); + } + @Test public void testUnsupportedTagName() throws Exception { FileStoreTable table = createFileStoreTable();