This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 1bfcc6645aa [feat](paimon) Display Paimon table properties in SHOW
CREATE TABLE (#53405)
1bfcc6645aa is described below
commit 1bfcc6645aafdedf9b3aa1dd2f816cf911475d20
Author: Petrichor <[email protected]>
AuthorDate: Mon Jul 28 12:10:01 2025 +0800
[feat](paimon) Display Paimon table properties in SHOW CREATE TABLE (#53405)
### What problem does this PR solve?
Currently, when executing SHOW CREATE TABLE on a Paimon table, the
output only displays the table schema without any table properties,
making it difficult for users to understand the complete table
configuration.
Before this PR:
```sql
mysql> show create table orders;
+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[...]
| Table | Create Table
[...]
+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[...]
| orders | CREATE TABLE `orders` (
`order_id` bigint NULL,
`customer_id` bigint NULL,
`order_date` datev2 NULL,
`total_amount` decimalv3(12,2) NULL,
`shipping_address` varchar(2147483647) NULL,
`order_status` varchar(2147483647) NULL,
`is_paid` boolean NULL,
`created_at` datetimev2(6) NULL
) ENGINE=PAIMON_EXTERNAL_TABLE
; |
+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[...]
1 row in set (0.01 sec)
```
After this PR:
```sql
mysql> show create table orders;
+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[...]
| Table | Create Table
[...]
+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[...]
| orders | CREATE TABLE `orders` (
`order_id` bigint NULL,
`customer_id` bigint NULL,
`order_date` datev2 NULL,
`total_amount` decimalv3(12,2) NULL,
`shipping_address` varchar(2147483647) NULL,
`order_status` varchar(2147483647) NULL,
`is_paid` boolean NULL,
`created_at` datetimev2(6) NULL
) ENGINE=PAIMON_EXTERNAL_TABLE
LOCATION 's3://paimon-dev/warehouse/doris_test.db/orders'
PROPERTIES (
"bucket" = "8",
"path" = "s3://paimon-dev/warehouse/doris_test.db/orders",
"write-mode" = "change-log",
"primary-key" = "order_id"
); |
+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[...]
```
---
.../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 241798ccaa6..17603923e7e 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
@@ -120,6 +120,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;
@@ -4286,6 +4287,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 6ea8951d0a1..371ce3864dd 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;
@@ -283,4 +285,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]