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 0bc6f91c3a [Improvement](multi catalog)Add comment to external hms 
table show create table output. (#14861)
0bc6f91c3a is described below

commit 0bc6f91c3abb0ac9e89bcba22ae1d454e1e44260
Author: Jibing-Li <64681310+jibing...@users.noreply.github.com>
AuthorDate: Wed Dec 7 21:12:30 2022 +0800

    [Improvement](multi catalog)Add comment to external hms table show create 
table output. (#14861)
    
    The output of show create table comment for hms external table doesn't 
contain comment section.
    This pr is to add the comment to the output.
---
 .../apache/doris/catalog/HiveMetaStoreClientHelper.java    | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/HiveMetaStoreClientHelper.java
 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/HiveMetaStoreClientHelper.java
index be75a1c983..e3aad211d6 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/HiveMetaStoreClientHelper.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/HiveMetaStoreClientHelper.java
@@ -96,6 +96,7 @@ public class HiveMetaStoreClientHelper {
     public static final String HIVE_METASTORE_URIS = "hive.metastore.uris";
     public static final String HIVE_METASTORE_TYPE = "hive.metastore.type";
     public static final String DLF_TYPE = "dlf";
+    public static final String COMMENT = "comment";
 
     private static final Pattern digitPattern = Pattern.compile("(\\d+)");
 
@@ -835,6 +836,9 @@ public class HiveMetaStoreClientHelper {
                 }
             }
             output.append(")\n");
+            if (remoteTable.getParameters().containsKey(COMMENT)) {
+                output.append(String.format("COMMENT '%s'", 
remoteTable.getParameters().get(COMMENT))).append("\n");
+            }
             if (remoteTable.getPartitionKeys().size() > 0) {
                 output.append("PARTITIONED BY (\n")
                         .append(remoteTable.getPartitionKeys().stream().map(
@@ -869,7 +873,15 @@ public class HiveMetaStoreClientHelper {
             }
             if (remoteTable.isSetParameters()) {
                 output.append("TBLPROPERTIES (\n");
-                Iterator<Map.Entry<String, String>> params = 
remoteTable.getParameters().entrySet().iterator();
+                Map<String, String> parameters = Maps.newHashMap();
+                // Copy the parameters to a new Map to keep them unchanged.
+                parameters.putAll(remoteTable.getParameters());
+                if (parameters.containsKey(COMMENT)) {
+                    // Comment is always added to the end of remote table 
parameters.
+                    // It has already showed above in COMMENT section, so 
remove it here.
+                    parameters.remove(COMMENT);
+                }
+                Iterator<Map.Entry<String, String>> params = 
parameters.entrySet().iterator();
                 while (params.hasNext()) {
                     Map.Entry<String, String> param = params.next();
                     output.append(String.format("  '%s'='%s'", param.getKey(), 
param.getValue()));


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to