This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new a9764b9d39f [chore](multi catalog) Print serde properties when show
create hive-external-table (#34966) (#37096)
a9764b9d39f is described below
commit a9764b9d39ff61d547b7b750d96b0a53be01a726
Author: Mingyu Chen <[email protected]>
AuthorDate: Tue Jul 2 11:07:10 2024 +0800
[chore](multi catalog) Print serde properties when show create
hive-external-table (#34966) (#37096)
bp #34966
Co-authored-by: xy720 <[email protected]>
---
.../datasource/hive/HiveMetaStoreClientHelper.java | 7 +++
.../hive/ddl/test_hive_show_create_table.groovy | 54 ++++++++++++++++++++++
2 files changed, 61 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreClientHelper.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreClientHelper.java
index aa3ff1ccee8..2e7693619b8 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreClientHelper.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetaStoreClientHelper.java
@@ -756,6 +756,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/ddl/test_hive_show_create_table.groovy
b/regression-test/suites/external_table_p0/hive/ddl/test_hive_show_create_table.groovy
new file mode 100644
index 00000000000..0b2af3e95f8
--- /dev/null
+++
b/regression-test/suites/external_table_p0/hive/ddl/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("hive2HmsPort")
+ String hdfs_port = context.config.otherConfigs.get("hive2HdfsPort")
+ 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: [email protected]
For additional commands, e-mail: [email protected]