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 1726d96ef5aa50..ed780a368863ba 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 static String showCreateTable(org.apache.hadoop.hive.metastore.api.Table 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 00000000000000..4235f9b4c1b6f9 --- /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}")) + } +}