This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 06cfebcb7c [Core] Correct identifer information in catalog enviroment
when using switch branch (#6898)
06cfebcb7c is described below
commit 06cfebcb7cbd4fba4c5023e8a01c619fbdce2fda
Author: Stefanietry <[email protected]>
AuthorDate: Thu Dec 25 23:03:17 2025 +0800
[Core] Correct identifer information in catalog enviroment when using
switch branch (#6898)
---
.../org/apache/paimon/table/AbstractFileStoreTable.java | 16 +++++++++++++++-
.../apache/paimon/table/PrimaryKeySimpleTableTest.java | 11 +++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git
a/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java
b/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java
index 2df64267cc..35949062e3 100644
---
a/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java
+++
b/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java
@@ -242,6 +242,16 @@ abstract class AbstractFileStoreTable implements
FileStoreTable {
return catalogEnvironment;
}
+ protected CatalogEnvironment newCatalogEnvironment(String branch) {
+ Identifier identifier = identifier();
+ return catalogEnvironment.copy(
+ new Identifier(
+ identifier.getDatabaseName(),
+ identifier.getTableName(),
+ branch,
+ identifier.getSystemTableName()));
+ }
+
public RowKeyExtractor createRowKeyExtractor() {
switch (bucketMode()) {
case HASH_FIXED:
@@ -719,7 +729,11 @@ abstract class AbstractFileStoreTable implements
FileStoreTable {
branchOptions.set(CoreOptions.BRANCH, targetBranch);
branchSchema = branchSchema.copy(branchOptions.toMap());
return FileStoreTableFactory.create(
- fileIO(), location(), branchSchema, new Options(),
catalogEnvironment());
+ fileIO(),
+ location(),
+ branchSchema,
+ new Options(),
+ newCatalogEnvironment(targetBranch));
}
private RollbackHelper rollbackHelper() {
diff --git
a/paimon-core/src/test/java/org/apache/paimon/table/PrimaryKeySimpleTableTest.java
b/paimon-core/src/test/java/org/apache/paimon/table/PrimaryKeySimpleTableTest.java
index 6e6519e8ec..3b9d7d2831 100644
---
a/paimon-core/src/test/java/org/apache/paimon/table/PrimaryKeySimpleTableTest.java
+++
b/paimon-core/src/test/java/org/apache/paimon/table/PrimaryKeySimpleTableTest.java
@@ -2549,6 +2549,17 @@ public class PrimaryKeySimpleTableTest extends
SimpleTableTestBase {
testWritePreemptMemory(true);
}
+ @Test
+ public void testSwitchBranch() throws Exception {
+ String branchName = "fallback";
+ FileStoreTable mainTable =
+ createFileStoreTable(options -> options.set(BUCKET,
BucketMode.POSTPONE_BUCKET));
+ mainTable.createBranch(branchName);
+ FileStoreTable branchTable = mainTable.switchToBranch(branchName);
+
assertThat(branchTable.catalogEnvironment().identifier().getBranchName())
+ .isEqualTo(branchName);
+ }
+
private void testWritePreemptMemory(boolean singlePartition) throws
Exception {
// write
FileStoreTable table =