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 888e1572cc [rest] Add isExternal to GetTableResponse (#5114)
888e1572cc is described below

commit 888e1572cca2a86e9fbc3e526f0aef50dc871da3
Author: Jingsong Lee <[email protected]>
AuthorDate: Thu Feb 20 11:49:28 2025 +0800

    [rest] Add isExternal to GetTableResponse (#5114)
---
 .../main/java/org/apache/paimon/catalog/AbstractCatalog.java  |  2 +-
 .../src/main/java/org/apache/paimon/catalog/CatalogUtils.java |  9 ++++++---
 .../main/java/org/apache/paimon/catalog/TableMetadata.java    |  8 +++++++-
 .../src/main/java/org/apache/paimon/rest/RESTCatalog.java     |  2 +-
 .../org/apache/paimon/rest/responses/GetTableResponse.java    | 11 +++++++++++
 .../src/test/java/org/apache/paimon/rest/MockRESTMessage.java |  2 +-
 .../test/java/org/apache/paimon/rest/RESTCatalogServer.java   |  2 +-
 .../src/test/java/org/apache/paimon/rest/TestRESTCatalog.java |  2 +-
 .../src/main/java/org/apache/paimon/hive/HiveCatalog.java     |  1 +
 paimon-open-api/rest-catalog-open-api.yaml                    |  2 ++
 .../org/apache/paimon/open/api/RESTCatalogController.java     |  1 +
 11 files changed, 33 insertions(+), 9 deletions(-)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java 
b/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java
index 508d8de625..87ae1b66f6 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/AbstractCatalog.java
@@ -401,7 +401,7 @@ public abstract class AbstractCatalog implements Catalog {
     }
 
     protected TableMetadata loadTableMetadata(Identifier identifier) throws 
TableNotExistException {
-        return new TableMetadata(loadTableSchema(identifier), null);
+        return new TableMetadata(loadTableSchema(identifier), false, null);
     }
 
     protected abstract TableSchema loadTableSchema(Identifier identifier)
diff --git 
a/paimon-core/src/main/java/org/apache/paimon/catalog/CatalogUtils.java 
b/paimon-core/src/main/java/org/apache/paimon/catalog/CatalogUtils.java
index 4726c375d9..14b49521bf 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/CatalogUtils.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/CatalogUtils.java
@@ -172,8 +172,8 @@ public class CatalogUtils {
     public static Table loadTable(
             Catalog catalog,
             Identifier identifier,
-            Function<Path, FileIO> dataFileIO,
-            Function<Path, FileIO> objectFileIO,
+            Function<Path, FileIO> internalFileIO,
+            Function<Path, FileIO> externalFileIO,
             TableMetadata.Loader metadataLoader,
             SnapshotCommit.Factory commitFactory)
             throws Catalog.TableNotExistException {
@@ -184,6 +184,9 @@ public class CatalogUtils {
         TableMetadata metadata = metadataLoader.load(identifier);
         TableSchema schema = metadata.schema();
         CoreOptions options = CoreOptions.fromMap(schema.options());
+
+        Function<Path, FileIO> dataFileIO = metadata.isExternal() ? 
externalFileIO : internalFileIO;
+
         if (options.type() == TableType.FORMAT_TABLE) {
             return toFormatTable(identifier, schema, dataFileIO);
         }
@@ -196,7 +199,7 @@ public class CatalogUtils {
                 FileStoreTableFactory.create(dataFileIO.apply(path), path, 
schema, catalogEnv);
 
         if (options.type() == TableType.OBJECT_TABLE) {
-            table = toObjectTable(objectFileIO, table);
+            table = toObjectTable(externalFileIO, table);
         }
 
         if (identifier.isSystemTable()) {
diff --git 
a/paimon-core/src/main/java/org/apache/paimon/catalog/TableMetadata.java 
b/paimon-core/src/main/java/org/apache/paimon/catalog/TableMetadata.java
index 81904476a2..b2a92ea11b 100644
--- a/paimon-core/src/main/java/org/apache/paimon/catalog/TableMetadata.java
+++ b/paimon-core/src/main/java/org/apache/paimon/catalog/TableMetadata.java
@@ -26,10 +26,12 @@ import javax.annotation.Nullable;
 public class TableMetadata {
 
     private final TableSchema schema;
+    private final boolean isExternal;
     @Nullable private final String uuid;
 
-    public TableMetadata(TableSchema schema, @Nullable String uuid) {
+    public TableMetadata(TableSchema schema, boolean isExternal, @Nullable 
String uuid) {
         this.schema = schema;
+        this.isExternal = isExternal;
         this.uuid = uuid;
     }
 
@@ -37,6 +39,10 @@ public class TableMetadata {
         return schema;
     }
 
+    public boolean isExternal() {
+        return isExternal;
+    }
+
     @Nullable
     public String uuid() {
         return uuid;
diff --git a/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java 
b/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java
index 61b422b8d1..c0c4db0dd3 100644
--- a/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java
+++ b/paimon-core/src/main/java/org/apache/paimon/rest/RESTCatalog.java
@@ -321,7 +321,7 @@ public class RESTCatalog implements Catalog {
         }
 
         TableSchema schema = TableSchema.create(response.getSchemaId(), 
response.getSchema());
-        return new TableMetadata(schema, response.getId());
+        return new TableMetadata(schema, response.isExternal(), 
response.getId());
     }
 
     @Override
diff --git 
a/paimon-core/src/main/java/org/apache/paimon/rest/responses/GetTableResponse.java
 
b/paimon-core/src/main/java/org/apache/paimon/rest/responses/GetTableResponse.java
index aeed030445..82b55fae7f 100644
--- 
a/paimon-core/src/main/java/org/apache/paimon/rest/responses/GetTableResponse.java
+++ 
b/paimon-core/src/main/java/org/apache/paimon/rest/responses/GetTableResponse.java
@@ -32,6 +32,7 @@ public class GetTableResponse implements RESTResponse {
 
     private static final String FIELD_ID = "id";
     private static final String FIELD_NAME = "name";
+    private static final String FIELD_IS_EXTERNAL = "isExternal";
     private static final String FIELD_SCHEMA_ID = "schemaId";
     private static final String FIELD_SCHEMA = "schema";
 
@@ -41,6 +42,9 @@ public class GetTableResponse implements RESTResponse {
     @JsonProperty(FIELD_NAME)
     private final String name;
 
+    @JsonProperty(FIELD_IS_EXTERNAL)
+    private final boolean isExternal;
+
     @JsonProperty(FIELD_SCHEMA_ID)
     private final long schemaId;
 
@@ -51,10 +55,12 @@ public class GetTableResponse implements RESTResponse {
     public GetTableResponse(
             @JsonProperty(FIELD_ID) String id,
             @JsonProperty(FIELD_NAME) String name,
+            @JsonProperty(FIELD_IS_EXTERNAL) boolean isExternal,
             @JsonProperty(FIELD_SCHEMA_ID) long schemaId,
             @JsonProperty(FIELD_SCHEMA) Schema schema) {
         this.id = id;
         this.name = name;
+        this.isExternal = isExternal;
         this.schemaId = schemaId;
         this.schema = schema;
     }
@@ -69,6 +75,11 @@ public class GetTableResponse implements RESTResponse {
         return this.name;
     }
 
+    @JsonGetter(FIELD_IS_EXTERNAL)
+    public boolean isExternal() {
+        return isExternal;
+    }
+
     @JsonGetter(FIELD_SCHEMA_ID)
     public long getSchemaId() {
         return this.schemaId;
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/rest/MockRESTMessage.java 
b/paimon-core/src/test/java/org/apache/paimon/rest/MockRESTMessage.java
index 83fab9a687..c3751e613e 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/MockRESTMessage.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/MockRESTMessage.java
@@ -230,7 +230,7 @@ public class MockRESTMessage {
         Map<String, String> options = new HashMap<>();
         options.put("option-1", "value-1");
         options.put("option-2", "value-2");
-        return new GetTableResponse(UUID.randomUUID().toString(), "", 1, 
schema(options));
+        return new GetTableResponse(UUID.randomUUID().toString(), "", false, 
1, schema(options));
     }
 
     public static AlterPartitionsRequest alterPartitionsRequest() {
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java 
b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java
index 37caaba944..4bde488d4b 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogServer.java
@@ -572,7 +572,7 @@ public class RESTCatalogServer {
                             table.options(),
                             table.comment().orElse(null));
         }
-        return new GetTableResponse(table.uuid(), table.name(), schemaId, 
schema);
+        return new GetTableResponse(table.uuid(), table.name(), false, 
schemaId, schema);
     }
 
     private static MockResponse mockResponse(RESTResponse response, int 
httpCode) {
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/rest/TestRESTCatalog.java 
b/paimon-core/src/test/java/org/apache/paimon/rest/TestRESTCatalog.java
index ec8fb18bd6..a812965310 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/TestRESTCatalog.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/TestRESTCatalog.java
@@ -253,7 +253,7 @@ public class TestRESTCatalog extends FileSystemCatalog {
     protected TableMetadata loadTableMetadata(Identifier identifier) throws 
TableNotExistException {
         if (tableFullName2Schema.containsKey(identifier.getFullName())) {
             TableSchema tableSchema = 
tableFullName2Schema.get(identifier.getFullName());
-            return new TableMetadata(tableSchema, "uuid");
+            return new TableMetadata(tableSchema, false, "uuid");
         }
         return super.loadTableMetadata(identifier);
     }
diff --git 
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java
 
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java
index 22f5565fb1..3fe13ed14c 100644
--- 
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java
+++ 
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java
@@ -703,6 +703,7 @@ public class HiveCatalog extends AbstractCatalog {
             throws TableNotExistException {
         return new TableMetadata(
                 loadTableSchema(identifier, table),
+                isExternalTable(table),
                 identifier.getFullName() + "." + table.getCreateTime());
     }
 
diff --git a/paimon-open-api/rest-catalog-open-api.yaml 
b/paimon-open-api/rest-catalog-open-api.yaml
index c5c4434402..dbdbfe1abe 100644
--- a/paimon-open-api/rest-catalog-open-api.yaml
+++ b/paimon-open-api/rest-catalog-open-api.yaml
@@ -995,6 +995,8 @@ components:
           type: string
         name:
           type: string
+        isExternal:
+          type: boolean
         schemaId:
           type: integer
           format: int64
diff --git 
a/paimon-open-api/src/main/java/org/apache/paimon/open/api/RESTCatalogController.java
 
b/paimon-open-api/src/main/java/org/apache/paimon/open/api/RESTCatalogController.java
index 3ffec9a5c3..934098226e 100644
--- 
a/paimon-open-api/src/main/java/org/apache/paimon/open/api/RESTCatalogController.java
+++ 
b/paimon-open-api/src/main/java/org/apache/paimon/open/api/RESTCatalogController.java
@@ -252,6 +252,7 @@ public class RESTCatalogController {
         return new GetTableResponse(
                 UUID.randomUUID().toString(),
                 "",
+                false,
                 1,
                 new org.apache.paimon.schema.Schema(
                         ImmutableList.of(),

Reply via email to