Skip to content

Commit de87c56

Browse files
committed
fix
1 parent f1a29b9 commit de87c56

File tree

7 files changed

+18
-14
lines changed

7 files changed

+18
-14
lines changed

paimon-core/src/main/java/org/apache/paimon/utils/BranchManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ public interface BranchManager {
4040

4141
List<String> branches();
4242

43+
default boolean branchExists(String branchName) {
44+
return branches().contains(branchName);
45+
}
46+
4347
/** Return the path string of a branch. */
4448
static String branchPath(Path tablePath, String branch) {
4549
return isMainBranch(branch)

paimon-core/src/test/java/org/apache/paimon/table/FileStoreTableTestBase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
import org.apache.paimon.types.DataTypes;
6767
import org.apache.paimon.types.RowKind;
6868
import org.apache.paimon.types.RowType;
69-
import org.apache.paimon.utils.FileSystemBranchManager;
69+
import org.apache.paimon.utils.BranchManager;
7070
import org.apache.paimon.utils.SnapshotManager;
7171
import org.apache.paimon.utils.TagManager;
7272
import org.apache.paimon.utils.TraceableFileIO;
@@ -1177,7 +1177,7 @@ public void testCreateBranch() throws Exception {
11771177
table.createBranch("test-branch", "test-tag");
11781178

11791179
// verify that branch file exist
1180-
FileSystemBranchManager branchManager = (FileSystemBranchManager) table.branchManager();
1180+
BranchManager branchManager = table.branchManager();
11811181
assertThat(branchManager.branchExists("test-branch")).isTrue();
11821182

11831183
// verify test-tag in test-branch is equal to snapshot 2
@@ -1261,7 +1261,7 @@ public void testDeleteBranch() throws Exception {
12611261
table.deleteBranch("branch1");
12621262

12631263
// verify that branch file not exist
1264-
FileSystemBranchManager branchManager = (FileSystemBranchManager) table.branchManager();
1264+
BranchManager branchManager = table.branchManager();
12651265
assertThat(branchManager.branchExists("branch1")).isFalse();
12661266

12671267
assertThatThrownBy(() -> table.deleteBranch("branch1"))
@@ -1927,7 +1927,7 @@ protected void generateBranch(FileStoreTable table) throws Exception {
19271927
table.createBranch(BRANCH_NAME, "tag1");
19281928

19291929
// verify that branch1 file exist
1930-
FileSystemBranchManager branchManager = (FileSystemBranchManager) table.branchManager();
1930+
BranchManager branchManager = table.branchManager();
19311931
assertThat(branchManager.branchExists(BRANCH_NAME)).isTrue();
19321932

19331933
// Verify branch1 and the main branch have the same data

paimon-core/src/test/java/org/apache/paimon/table/system/AggregationFieldsTableTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.apache.paimon.table.FileStoreTable;
3333
import org.apache.paimon.table.TableTestBase;
3434
import org.apache.paimon.types.DataTypes;
35-
import org.apache.paimon.utils.FileSystemBranchManager;
35+
import org.apache.paimon.utils.BranchManager;
3636

3737
import org.apache.paimon.shade.guava30.com.google.common.collect.Multimap;
3838

@@ -91,7 +91,7 @@ public void testBranchAggregationFieldsRecord() throws Exception {
9191
FileStoreTable table = (FileStoreTable) catalog.getTable(identifier(tableName));
9292
table.createBranch("b1");
9393
// verify that branch file exist
94-
FileSystemBranchManager branchManager = (FileSystemBranchManager) table.branchManager();
94+
BranchManager branchManager = table.branchManager();
9595
assertThat(branchManager.branchExists("b1")).isTrue();
9696

9797
SchemaManager schemaManagerBranch = schemaManager.copyWithBranch("b1");

paimon-core/src/test/java/org/apache/paimon/table/system/OptionsTableTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.apache.paimon.table.FileStoreTable;
3333
import org.apache.paimon.table.TableTestBase;
3434
import org.apache.paimon.types.DataTypes;
35-
import org.apache.paimon.utils.FileSystemBranchManager;
35+
import org.apache.paimon.utils.BranchManager;
3636

3737
import org.junit.jupiter.api.BeforeEach;
3838
import org.junit.jupiter.api.Test;
@@ -86,7 +86,7 @@ public void testBranchOptionsTable() throws Exception {
8686
FileStoreTable table = (FileStoreTable) catalog.getTable(identifier(tableName));
8787
table.createBranch("b1");
8888
// verify that branch file exist
89-
FileSystemBranchManager branchManager = (FileSystemBranchManager) table.branchManager();
89+
BranchManager branchManager = table.branchManager();
9090
assertThat(branchManager.branchExists("b1")).isTrue();
9191
SchemaManager schemaManagerBranch = schemaManager.copyWithBranch("b1");
9292
Map<String, String> newOptions = new HashMap<>();

paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/action/BranchActionITCase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.apache.paimon.types.DataType;
2727
import org.apache.paimon.types.DataTypes;
2828
import org.apache.paimon.types.RowType;
29-
import org.apache.paimon.utils.FileSystemBranchManager;
29+
import org.apache.paimon.utils.BranchManager;
3030
import org.apache.paimon.utils.SnapshotManager;
3131
import org.apache.paimon.utils.TagManager;
3232

@@ -76,7 +76,7 @@ void testCreateAndDeleteBranch() throws Exception {
7676
"CALL sys.create_tag('%s.%s', 'tag2', 2, '5 d')", database, tableName));
7777
assertThat(tagManager.tagExists("tag2")).isTrue();
7878

79-
FileSystemBranchManager branchManager = (FileSystemBranchManager) table.branchManager();
79+
BranchManager branchManager = table.branchManager();
8080
executeSQL(
8181
String.format(
8282
"CALL sys.create_branch('%s.%s', 'branch_name', 'tag2')",
@@ -157,7 +157,7 @@ void testCreateAndDeleteEmptyBranch() throws Exception {
157157
writeData(rowData(2L, BinaryString.fromString("Hello")));
158158
writeData(rowData(3L, BinaryString.fromString("Paimon")));
159159

160-
FileSystemBranchManager branchManager = (FileSystemBranchManager) table.branchManager();
160+
BranchManager branchManager = table.branchManager();
161161
executeSQL(
162162
String.format(
163163
"CALL sys.create_branch('%s.%s', 'empty_branch_name')",
@@ -244,7 +244,7 @@ void testFastForward() throws Exception {
244244
assertThat(tagManager.tagExists("tag3")).isTrue();
245245

246246
// Create branch_name branch
247-
FileSystemBranchManager branchManager = (FileSystemBranchManager) table.branchManager();
247+
BranchManager branchManager = table.branchManager();
248248
executeSQL(
249249
String.format(
250250
"CALL sys.create_branch('%s.%s', 'branch_name', 'tag2')",

paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/procedure/AlterBranchProcedureTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class AlterBranchProcedureTest extends PaimonSparkTestBase with StreamTest {
6868
checkAnswer(query(), Row(1, "a") :: Row(2, "b2") :: Nil)
6969

7070
val table = loadTable("T")
71-
val branchManager = table.branchManager().asInstanceOf[FileSystemBranchManager]
71+
val branchManager = table.branchManager()
7272

7373
// create branch with tag
7474
checkAnswer(

paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/procedure/BranchProcedureTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class BranchProcedureTest extends PaimonSparkTestBase with StreamTest {
8484
"CALL paimon.sys.create_branch(table => 'test.T', branch => 'test_branch', tag => 'test_tag')"),
8585
Row(true) :: Nil)
8686
val table = loadTable("T")
87-
val branchManager = table.branchManager().asInstanceOf[FileSystemBranchManager]
87+
val branchManager = table.branchManager()
8888
assert(branchManager.branchExists("test_branch"))
8989

9090
// query from branch

0 commit comments

Comments
 (0)