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 ff2b49cb1b [core] fix fallback branch cannot query data in rest 
catalog (#5714)
ff2b49cb1b is described below

commit ff2b49cb1b34168f8c4b6d978fcdff0cc3076358
Author: kevin <[email protected]>
AuthorDate: Sun Jun 8 11:09:09 2025 +0800

    [core] fix fallback branch cannot query data in rest catalog (#5714)
---
 .../org/apache/paimon/table/CatalogEnvironment.java     | 10 ++++++++++
 .../org/apache/paimon/table/FileStoreTableFactory.java  | 17 ++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/table/CatalogEnvironment.java 
b/paimon-core/src/main/java/org/apache/paimon/table/CatalogEnvironment.java
index fd20d88951..fbc1b894a4 100644
--- a/paimon-core/src/main/java/org/apache/paimon/table/CatalogEnvironment.java
+++ b/paimon-core/src/main/java/org/apache/paimon/table/CatalogEnvironment.java
@@ -132,6 +132,16 @@ public class CatalogEnvironment implements Serializable {
         return catalogLoader;
     }
 
+    public CatalogEnvironment copy(Identifier identifier) {
+        return new CatalogEnvironment(
+                identifier,
+                uuid,
+                catalogLoader,
+                lockFactory,
+                lockContext,
+                supportsVersionManagement);
+    }
+
     public TableQueryAuth tableQueryAuth(CoreOptions options) {
         if (!options.queryAuthEnabled() || catalogLoader == null) {
             return select -> Collections.emptyList();
diff --git 
a/paimon-core/src/main/java/org/apache/paimon/table/FileStoreTableFactory.java 
b/paimon-core/src/main/java/org/apache/paimon/table/FileStoreTableFactory.java
index afa7a5f3b0..06fc9b3020 100644
--- 
a/paimon-core/src/main/java/org/apache/paimon/table/FileStoreTableFactory.java
+++ 
b/paimon-core/src/main/java/org/apache/paimon/table/FileStoreTableFactory.java
@@ -20,6 +20,7 @@ package org.apache.paimon.table;
 
 import org.apache.paimon.CoreOptions;
 import org.apache.paimon.catalog.CatalogContext;
+import org.apache.paimon.catalog.Identifier;
 import org.apache.paimon.fs.FileIO;
 import org.apache.paimon.fs.Path;
 import org.apache.paimon.options.Options;
@@ -103,9 +104,23 @@ public class FileStoreTableFactory {
             Optional<TableSchema> schema =
                     new SchemaManager(fileIO, tablePath, 
fallbackBranch).latest();
             if (schema.isPresent()) {
+                Identifier identifier = catalogEnvironment.identifier();
+                CatalogEnvironment fallbackCatalogEnvironment = 
catalogEnvironment;
+                if (identifier != null) {
+                    fallbackCatalogEnvironment =
+                            catalogEnvironment.copy(
+                                    new Identifier(
+                                            identifier.getDatabaseName(),
+                                            identifier.getObjectName(),
+                                            fallbackBranch));
+                }
                 FileStoreTable fallbackTable =
                         createWithoutFallbackBranch(
-                                fileIO, tablePath, schema.get(), 
branchOptions, catalogEnvironment);
+                                fileIO,
+                                tablePath,
+                                schema.get(),
+                                branchOptions,
+                                fallbackCatalogEnvironment);
                 table = new FallbackReadFileStoreTable(table, fallbackTable);
             } else {
                 LOG.error("Fallback branch {} not found for table {}", 
fallbackBranch, tablePath);

Reply via email to