This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new cfb37132aa4 branch-3.1: [feat](paimon) Display Paimon table properties 
in SHOW CREATE TABLE #53405 (#53963)
cfb37132aa4 is described below

commit cfb37132aa4c4b55276cda9add04a3a20601db99
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Jul 29 08:22:22 2025 +0800

    branch-3.1: [feat](paimon) Display Paimon table properties in SHOW CREATE 
TABLE #53405 (#53963)
    
    Cherry-picked from #53405
    
    Co-authored-by: Petrichor <[email protected]>
---
 .../main/java/org/apache/doris/catalog/Env.java    |  16 +++++++
 .../datasource/paimon/PaimonExternalTable.java     |  23 +++++++++++
 .../paimon/test_paimon_table_properties.out        | Bin 0 -> 934 bytes
 .../paimon/test_paimon_table_properties.groovy     |  46 +++++++++++++++++++++
 4 files changed, 85 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index 587d9ae9beb..e42483a65bf 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -145,6 +145,7 @@ import org.apache.doris.datasource.es.EsRepository;
 import org.apache.doris.datasource.hive.HiveTransactionMgr;
 import org.apache.doris.datasource.hive.event.MetastoreEventsProcessor;
 import org.apache.doris.datasource.iceberg.IcebergExternalTable;
+import org.apache.doris.datasource.paimon.PaimonExternalTable;
 import org.apache.doris.deploy.DeployManager;
 import org.apache.doris.deploy.impl.AmbariDeployManager;
 import org.apache.doris.deploy.impl.K8sDeployManager;
@@ -4218,6 +4219,21 @@ public class Env {
                 }
             }
             sb.append("\n)");
+        } else if (table.getType() == TableType.PAIMON_EXTERNAL_TABLE) {
+            addTableComment(table, sb);
+            PaimonExternalTable paimonExternalTable = (PaimonExternalTable) 
table;
+            Map<String, String> properties = 
paimonExternalTable.getTableProperties();
+            sb.append("\nLOCATION '").append(properties.getOrDefault("path", 
"")).append("'");
+            sb.append("\nPROPERTIES (");
+            Iterator<Entry<String, String>> iterator = 
properties.entrySet().iterator();
+            while (iterator.hasNext()) {
+                Entry<String, String> prop = iterator.next();
+                sb.append("\n  \"").append(prop.getKey()).append("\" = 
\"").append(prop.getValue()).append("\"");
+                if (iterator.hasNext()) {
+                    sb.append(",");
+                }
+            }
+            sb.append("\n)");
         }
 
         createTableStmt.add(sb + ";");
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalTable.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalTable.java
index 38f8c9122b7..b6df52edda1 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalTable.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/PaimonExternalTable.java
@@ -53,6 +53,7 @@ import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
+import org.apache.paimon.CoreOptions;
 import org.apache.paimon.partition.Partition;
 import org.apache.paimon.schema.TableSchema;
 import org.apache.paimon.table.DataTable;
@@ -62,6 +63,7 @@ import org.apache.paimon.types.DataField;
 
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -273,4 +275,25 @@ public class PaimonExternalTable extends ExternalTable 
implements MTMVRelatedTab
         makeSureInitialized();
         return SupportedSysTables.PAIMON_SUPPORTED_SYS_TABLES;
     }
+
+    @Override
+    public String getComment() {
+        return paimonTable.comment().isPresent() ? paimonTable.comment().get() 
: "";
+    }
+
+    public Map<String, String> getTableProperties() {
+
+        if (paimonTable instanceof DataTable) {
+            DataTable dataTable = (DataTable) paimonTable;
+            Map<String, String> properties = new 
LinkedHashMap<>(dataTable.coreOptions().toMap());
+
+            if (!dataTable.primaryKeys().isEmpty()) {
+                properties.put(CoreOptions.PRIMARY_KEY.key(), String.join(",", 
dataTable.primaryKeys()));
+            }
+
+            return properties;
+        } else {
+            return Collections.emptyMap();
+        }
+    }
 }
diff --git 
a/regression-test/data/external_table_p0/paimon/test_paimon_table_properties.out
 
b/regression-test/data/external_table_p0/paimon/test_paimon_table_properties.out
new file mode 100644
index 00000000000..68539532205
Binary files /dev/null and 
b/regression-test/data/external_table_p0/paimon/test_paimon_table_properties.out
 differ
diff --git 
a/regression-test/suites/external_table_p0/paimon/test_paimon_table_properties.groovy
 
b/regression-test/suites/external_table_p0/paimon/test_paimon_table_properties.groovy
new file mode 100644
index 00000000000..c051d148bcb
--- /dev/null
+++ 
b/regression-test/suites/external_table_p0/paimon/test_paimon_table_properties.groovy
@@ -0,0 +1,46 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_paimon_table_properties", 
"p0,external,doris,external_docker,external_docker_doris") {
+    String enabled = context.config.otherConfigs.get("enablePaimonTest")
+    if (enabled != null && enabled.equalsIgnoreCase("true")) {
+        String minio_port = 
context.config.otherConfigs.get("iceberg_minio_port")
+        String catalog_name = "test_paimon_minio"
+        String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+        String table_name = "ts_scale_orc"
+
+        sql """drop catalog if exists ${catalog_name}"""
+
+        sql """
+                CREATE CATALOG ${catalog_name} PROPERTIES (
+                        'type' = 'paimon',
+                        'warehouse' = 's3://warehouse/wh',
+                        's3.endpoint' = 
'http://${externalEnvIp}:${minio_port}',
+                        's3.access_key' = 'admin',
+                        's3.secret_key' = 'password',
+                        's3.path.style.access' = 'true'
+                );
+            """
+        sql """switch `${catalog_name}`"""
+        sql """use `${catalog_name}`.`flink_paimon`"""
+        qt_show_create_table """show create table ${table_name} """
+
+        sql """drop catalog if exists ${catalog_name}_with_region"""
+    }
+}
+
+


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to