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

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


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new c0deda55ab1 [branch-2.0](multi catalog) Print serde properties when 
show create hive-external-table (#34967)
c0deda55ab1 is described below

commit c0deda55ab123d6d8edc37269316245bf10de9b6
Author: xy720 <22125576+xy...@users.noreply.github.com>
AuthorDate: Tue May 21 15:52:08 2024 +0800

    [branch-2.0](multi catalog) Print serde properties when show create 
hive-external-table (#34967)
---
 .../doris/catalog/HiveMetaStoreClientHelper.java   |  7 +++
 .../hive/test_hive_show_create_table.groovy        | 54 ++++++++++++++++++++++
 2 files changed, 61 insertions(+)

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 1726d96ef5a..ed780a36886 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
@@ -857,6 +857,13 @@ public class HiveMetaStoreClientHelper {
                 output.append("ROW FORMAT SERDE\n")
                         .append(String.format("  '%s'\n", 
descriptor.getSerdeInfo().getSerializationLib()));
             }
+            if (descriptor.getSerdeInfo().isSetParameters()) {
+                output.append("WITH SERDEPROPERTIES (\n")
+                        
.append(descriptor.getSerdeInfo().getParameters().entrySet().stream()
+                        .map(entry -> String.format("  '%s' = '%s'", 
entry.getKey(), entry.getValue()))
+                        .collect(Collectors.joining(",\n")))
+                        .append(")\n");
+            }
             if (descriptor.isSetInputFormat()) {
                 output.append("STORED AS INPUTFORMAT\n")
                         .append(String.format("  '%s'\n", 
descriptor.getInputFormat()));
diff --git 
a/regression-test/suites/external_table_p0/hive/test_hive_show_create_table.groovy
 
b/regression-test/suites/external_table_p0/hive/test_hive_show_create_table.groovy
new file mode 100644
index 00000000000..4235f9b4c1b
--- /dev/null
+++ 
b/regression-test/suites/external_table_p0/hive/test_hive_show_create_table.groovy
@@ -0,0 +1,54 @@
+// 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_hive_show_create_table", 
"p0,external,hive,external_docker,external_docker_hive") {
+    String enabled = context.config.otherConfigs.get("enableHiveTest")
+    if (enabled != null && enabled.equalsIgnoreCase("true")) {
+        String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+        String hms_port = context.config.otherConfigs.get("hms_port")
+        String hdfs_port = context.config.otherConfigs.get("hms_port")
+        String catalog_name = "test_hive_show_create_table"
+        String table_name = "table_with_pars";
+
+        sql """drop catalog if exists ${catalog_name};"""
+
+        sql """
+            create catalog if not exists ${catalog_name} properties (
+                'type'='hms',
+                'hive.metastore.uris' = 
'thrift://${externalEnvIp}:${hms_port}',
+                'fs.defaultFS' = 'hdfs://${externalEnvIp}:${hdfs_port}'
+            );
+        """
+        logger.info("catalog " + catalog_name + " created")
+        sql """switch ${catalog_name};"""
+        logger.info("switched to catalog " + catalog_name)
+        sql """use `default`;"""
+
+        def serde = "'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'"
+        def serdeFormat = "'serialization.format' = '|'"
+        def filedDelim = "'field.delim' = '|'"
+        def inputFormat = "'org.apache.hadoop.mapred.TextInputFormat'"
+        def outputFormat = 
"'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'"
+        def create_tbl_res = sql """ show create table table_with_pars """
+        logger.info("${create_tbl_res}")
+        assertTrue(create_tbl_res.toString().containsIgnoreCase("${serde}"))
+        
assertTrue(create_tbl_res.toString().containsIgnoreCase("${serdeFormat}"))
+        
assertTrue(create_tbl_res.toString().containsIgnoreCase("${filedDelim}"))
+        
assertTrue(create_tbl_res.toString().containsIgnoreCase("${inputFormat}"))
+        
assertTrue(create_tbl_res.toString().containsIgnoreCase("${outputFormat}"))
+    }
+}


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

Reply via email to