From 630de740eae08ff3b15e152575dd1e23784c8057 Mon Sep 17 00:00:00 2001 From: Yulei-Yang Date: Thu, 7 Dec 2023 10:17:25 +0800 Subject: [PATCH] [fix](meta) fix bug for using full name in show_full_columns stmt (#28019) --- .../org/apache/doris/qe/ShowExecutor.java | 2 +- .../hive/test_show_columns.groovy | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 regression-test/suites/external_table_p0/hive/test_show_columns.groovy diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java index e4d4c04291..c7643c8e58 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java @@ -1005,7 +1005,7 @@ public class ShowExecutor { private void handleShowColumn() throws AnalysisException { ShowColumnStmt showStmt = (ShowColumnStmt) stmt; List> rows = Lists.newArrayList(); - DatabaseIf db = ctx.getCurrentCatalog().getDbOrAnalysisException(showStmt.getDb()); + DatabaseIf db = Env.getCurrentEnv().getInternalCatalog().getDbOrAnalysisException(showStmt.getDb()); TableIf table = db.getTableOrAnalysisException(showStmt.getTable()); PatternMatcher matcher = null; if (showStmt.getPattern() != null) { diff --git a/regression-test/suites/external_table_p0/hive/test_show_columns.groovy b/regression-test/suites/external_table_p0/hive/test_show_columns.groovy new file mode 100644 index 0000000000..e7c751839a --- /dev/null +++ b/regression-test/suites/external_table_p0/hive/test_show_columns.groovy @@ -0,0 +1,62 @@ +// 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_show_colums", "p0,external,hive,external_docker,external_docker_hive") { + + sql """create database if not exists db1""" + sql """drop table if exists db1.test_full_column""" + sql '''create table db1.test_full_column ( + id int not null, + name varchar(20) not null + ) + distributed by hash(id) buckets 4 + properties ( + "replication_num"="1" + ); + ''' + result = sql """show full columns from db1.test_full_column""" + assertEquals(result.size(), 2) + assertEquals(result[0][0], "id") + + String enabled = context.config.otherConfigs.get("enableHiveTest") + if (enabled != null && enabled.equalsIgnoreCase("true")) { + String hms_port = context.config.otherConfigs.get("hms_port") + String externalEnvIp = context.config.otherConfigs.get("externalEnvIp") + + String catalog_name = "hive_test_other" + + 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}' + );""" + + sql """switch ${catalog_name}""" + + result = sql """show full columns from internal.db1.test_full_column""" + assertEquals(result.size(), 2) + assertEquals(result[0][0], "id") + + sql """switch internal""" + + result = sql """show full columns from internal.db1.test_full_column""" + assertEquals(result.size(), 2) + assertEquals(result[1][0], "name") + + sql """drop catalog if exists ${catalog_name}""" + } +}