Skip to content

Commit 71a5971

Browse files
committed
fix
1 parent 6f234ee commit 71a5971

File tree

10 files changed

+24
-22
lines changed

10 files changed

+24
-22
lines changed

paimon-core/src/main/java/org/apache/paimon/catalog/Identifier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.apache.paimon.types.DataField;
2323
import org.apache.paimon.types.DataTypes;
2424
import org.apache.paimon.types.RowType;
25-
import org.apache.paimon.utils.FileSystemBranchManager;
25+
import org.apache.paimon.utils.BranchManager;
2626
import org.apache.paimon.utils.Preconditions;
2727
import org.apache.paimon.utils.StringUtils;
2828

@@ -139,7 +139,7 @@ public String getTableName() {
139139
@JsonIgnore
140140
public String getBranchNameOrDefault() {
141141
String branch = getBranchName();
142-
return branch == null ? FileSystemBranchManager.DEFAULT_MAIN_BRANCH : branch;
142+
return branch == null ? BranchManager.DEFAULT_MAIN_BRANCH : branch;
143143
}
144144

145145
@JsonIgnore

paimon-core/src/main/java/org/apache/paimon/operation/OrphanFilesClean.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
import org.apache.paimon.manifest.ManifestList;
3131
import org.apache.paimon.schema.SchemaManager;
3232
import org.apache.paimon.table.FileStoreTable;
33+
import org.apache.paimon.utils.BranchManager;
3334
import org.apache.paimon.utils.ChangelogManager;
3435
import org.apache.paimon.utils.DateTimeUtils;
3536
import org.apache.paimon.utils.FileStorePathFactory;
36-
import org.apache.paimon.utils.FileSystemBranchManager;
3737
import org.apache.paimon.utils.Pair;
3838
import org.apache.paimon.utils.Preconditions;
3939
import org.apache.paimon.utils.SnapshotManager;
@@ -108,7 +108,7 @@ public OrphanFilesClean(FileStoreTable table, long olderThanMillis, boolean dryR
108108

109109
protected List<String> validBranches() {
110110
List<String> branches = table.branchManager().branches();
111-
branches.add(FileSystemBranchManager.DEFAULT_MAIN_BRANCH);
111+
branches.add(BranchManager.DEFAULT_MAIN_BRANCH);
112112

113113
List<String> abnormalBranches = new ArrayList<>();
114114
for (String branch : branches) {

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/FileStoreITCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
import org.apache.paimon.table.FileStoreTable;
3434
import org.apache.paimon.table.FileStoreTableFactory;
3535
import org.apache.paimon.utils.BlockingIterator;
36+
import org.apache.paimon.utils.BranchManager;
3637
import org.apache.paimon.utils.FailingFileIO;
37-
import org.apache.paimon.utils.FileSystemBranchManager;
3838

3939
import org.apache.flink.api.common.eventtime.WatermarkStrategy;
4040
import org.apache.flink.api.common.functions.MapFunction;
@@ -139,7 +139,7 @@ public FileStoreITCase(boolean isBatch) {
139139

140140
@BeforeAll
141141
public static void before() {
142-
branch = FileSystemBranchManager.DEFAULT_MAIN_BRANCH;
142+
branch = BranchManager.DEFAULT_MAIN_BRANCH;
143143
}
144144

145145
@Parameters(name = "isBatch-{0}")

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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.paimon.spark.procedure
2020

2121
import org.apache.paimon.spark.PaimonSparkTestBase
22-
import org.apache.paimon.utils.FileSystemBranchManager
2322

2423
import org.apache.spark.sql.{Dataset, Row}
2524
import org.apache.spark.sql.execution.streaming.MemoryStream
@@ -68,7 +67,7 @@ class AlterBranchProcedureTest extends PaimonSparkTestBase with StreamTest {
6867
checkAnswer(query(), Row(1, "a") :: Row(2, "b2") :: Nil)
6968

7069
val table = loadTable("T")
71-
val branchManager = table.branchManager().asInstanceOf[FileSystemBranchManager]
70+
val branchManager = table.branchManager()
7271

7372
// create branch with tag
7473
checkAnswer(

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.apache.paimon.spark.procedure
2020

2121
import org.apache.paimon.spark.PaimonSparkTestBase
22-
import org.apache.paimon.utils.FileSystemBranchManager
2322

2423
import org.apache.spark.sql.{Dataset, Row}
2524
import org.apache.spark.sql.execution.streaming.MemoryStream
@@ -84,7 +83,7 @@ class BranchProcedureTest extends PaimonSparkTestBase with StreamTest {
8483
"CALL paimon.sys.create_branch(table => 'test.T', branch => 'test_branch', tag => 'test_tag')"),
8584
Row(true) :: Nil)
8685
val table = loadTable("T")
87-
val branchManager = table.branchManager().asInstanceOf[FileSystemBranchManager]
86+
val branchManager = table.branchManager()
8887
assert(branchManager.branchExists("test_branch"))
8988

9089
// query from branch

0 commit comments

Comments
 (0)