diff --git a/regression-test/data/external_table_p0/hive/test_information_schema_external.out b/regression-test/data/external_table_p0/hive/test_information_schema_external.out new file mode 100644 index 00000000000000..7cb812c7800393 --- /dev/null +++ b/regression-test/data/external_table_p0/hive/test_information_schema_external.out @@ -0,0 +1,133 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !schemata_1 -- +test_information_schema_external default utf8 utf8_general_ci \N + +-- !schemata_2 -- +internal info_schema_ext_db_1 utf8 utf8_general_ci \N + +-- !schemata_3 -- +internal info_schema_ext_db_2 utf8 utf8_general_ci \N + +-- !schemata_4 -- + +-- !schemata_5 -- +internal info_schema_ext_db_2 utf8 utf8_general_ci \N + +-- !schemata_6 -- + +-- !schemata_7 -- + +-- !schemata_8 -- + +-- !schemata_9 -- + +-- !columns_1 -- +internal info_schema_ext_db abcd id 1 \N NO int \N \N 10 0 \N \N \N int(11) UNI 10 0 \N \N +internal info_schema_ext_db abcd name 2 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N + +-- !columns_2 -- +internal info_schema_ext_db abcd id 1 \N NO int \N \N 10 0 \N \N \N int(11) UNI 10 0 \N \N +internal info_schema_ext_db abcd name 2 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N + +-- !columns_3 -- +test_information_schema_external tpch1_parquet customer c_acctbal 6 \N YES decimal \N \N 12 2 \N \N \N decimalv3(12, 2) 12 2 \N \N +test_information_schema_external tpch1_parquet customer c_address 3 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet customer c_comment 8 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet customer c_custkey 1 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N +test_information_schema_external tpch1_parquet customer c_mktsegment 7 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet customer c_name 2 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet customer c_nationkey 4 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N +test_information_schema_external tpch1_parquet customer c_phone 5 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N + +-- !columns_4 -- +test_information_schema_external tpch1_parquet lineitem l_comment 16 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet lineitem l_commitdate 12 \N YES date \N \N \N \N \N \N \N date \N \N \N \N +test_information_schema_external tpch1_parquet lineitem l_discount 7 \N YES decimal \N \N 12 2 \N \N \N decimalv3(12, 2) 12 2 \N \N +test_information_schema_external tpch1_parquet lineitem l_extendedprice 6 \N YES decimal \N \N 12 2 \N \N \N decimalv3(12, 2) 12 2 \N \N +test_information_schema_external tpch1_parquet lineitem l_linenumber 4 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N +test_information_schema_external tpch1_parquet lineitem l_linestatus 10 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet lineitem l_orderkey 1 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N +test_information_schema_external tpch1_parquet lineitem l_partkey 2 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N +test_information_schema_external tpch1_parquet lineitem l_quantity 5 \N YES decimal \N \N 12 2 \N \N \N decimalv3(12, 2) 12 2 \N \N +test_information_schema_external tpch1_parquet lineitem l_receiptdate 13 \N YES date \N \N \N \N \N \N \N date \N \N \N \N +test_information_schema_external tpch1_parquet lineitem l_returnflag 9 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet lineitem l_shipdate 11 \N YES date \N \N \N \N \N \N \N date \N \N \N \N +test_information_schema_external tpch1_parquet lineitem l_shipinstruct 14 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet lineitem l_shipmode 15 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet lineitem l_suppkey 3 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N +test_information_schema_external tpch1_parquet lineitem l_tax 8 \N YES decimal \N \N 12 2 \N \N \N decimalv3(12, 2) 12 2 \N \N + +-- !columns_5 -- +test_information_schema_external tpch1_parquet nation n_comment 4 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet nation n_name 2 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet nation n_nationkey 1 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N +test_information_schema_external tpch1_parquet nation n_regionkey 3 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N + +-- !columns_6 -- +test_information_schema_external tpch1_parquet orders o_clerk 7 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet orders o_comment 9 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet orders o_custkey 2 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N +test_information_schema_external tpch1_parquet orders o_orderdate 5 \N YES date \N \N \N \N \N \N \N date \N \N \N \N +test_information_schema_external tpch1_parquet orders o_orderkey 1 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N +test_information_schema_external tpch1_parquet orders o_orderpriority 6 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet orders o_orderstatus 3 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet orders o_shippriority 8 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N +test_information_schema_external tpch1_parquet orders o_totalprice 4 \N YES decimal \N \N 12 2 \N \N \N decimalv3(12, 2) 12 2 \N \N + +-- !columns_7 -- +test_information_schema_external tpch1_parquet partsupp ps_availqty 3 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N +test_information_schema_external tpch1_parquet partsupp ps_comment 5 \N YES varchar 2147483643 8589934572 \N \N \N \N \N string 2147483643 \N \N \N +test_information_schema_external tpch1_parquet partsupp ps_partkey 1 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N +test_information_schema_external tpch1_parquet partsupp ps_suppkey 2 \N YES int \N \N 10 0 \N \N \N int(11) 10 0 \N \N +test_information_schema_external tpch1_parquet partsupp ps_supplycost 4 \N YES decimal \N \N 12 2 \N \N \N decimalv3(12, 2) 12 2 \N \N + +-- !ids_1 -- +test_information_schema_external tpch1_parquet customer + +-- !ids_2 -- +test_information_schema_external tpch1_parquet lineitem + +-- !ids_3 -- +test_information_schema_external tpch1_parquet nation + +-- !ids_4 -- +test_information_schema_external tpch1_parquet orders + +-- !ids_5 -- +test_information_schema_external tpch1_parquet part + +-- !ids_6 -- +test_information_schema_external tpch1_parquet partsupp + +-- !ids_7 -- +test_information_schema_external tpch1_parquet region + +-- !ids_8 -- +test_information_schema_external tpch1_parquet supplier + +-- !tables_1 -- +test_information_schema_external tpch1_parquet supplier HMS_EXTERNAL_TABLE \N 0 \N + +-- !tables_2 -- +test_information_schema_external tpch1_parquet region HMS_EXTERNAL_TABLE \N 0 \N + +-- !tables_3 -- +test_information_schema_external tpch1_parquet customer HMS_EXTERNAL_TABLE \N 0 \N + +-- !tables_4 -- +test_information_schema_external tpch1_parquet lineitem HMS_EXTERNAL_TABLE \N 0 \N + +-- !tables_5 -- +test_information_schema_external tpch1_parquet nation HMS_EXTERNAL_TABLE \N 0 \N + +-- !tables_6 -- +test_information_schema_external tpch1_parquet orders HMS_EXTERNAL_TABLE \N 0 \N + +-- !tables_7 -- +test_information_schema_external tpch1_parquet partsupp HMS_EXTERNAL_TABLE \N 0 \N + +-- !views_1 -- +\N info_schema_ext_db test_view NONE NO root@% DEFINER utf8 \N + +-- !views_2 -- + diff --git a/regression-test/suites/external_table_p0/hive/test_information_schema_external.groovy b/regression-test/suites/external_table_p0/hive/test_information_schema_external.groovy new file mode 100644 index 00000000000000..0655d3a231734f --- /dev/null +++ b/regression-test/suites/external_table_p0/hive/test_information_schema_external.groovy @@ -0,0 +1,227 @@ +// 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_information_schema_external", "p0,external,hive,external_docker,external_docker_hive") { + // test schemata 、columns、files、metadata_name_ids、partitions、tables、views + //files partitions no imp + + def enabled = context.config.otherConfigs.get("enableHiveTest") + def externalEnvIp = context.config.otherConfigs.get("externalEnvIp") + + if (enabled != null && enabled.equalsIgnoreCase("true")) { + try { + def hms_port = context.config.otherConfigs.get("hms_port") + def catalog_name = "test_information_schema_external" + 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}' + );""" + + def db_name = "info_schema_ext_db" + + //schemata + order_qt_schemata_1 """ + select * from internal.information_schema.schemata + where CATALOG_NAME = "${catalog_name}" and SCHEMA_NAME = "default"; + """ + sql """ create database if not exists ${db_name}_1; """ + sql """ create database if not exists ${db_name}_2; """ + order_qt_schemata_2 """ + select * from internal.information_schema.schemata + where CATALOG_NAME = "internal" and SCHEMA_NAME = "${db_name}_1"; + """ + order_qt_schemata_3 """ + select * from internal.information_schema.schemata + where CATALOG_NAME = "internal" and SCHEMA_NAME = "${db_name}_2"; + """ + sql """ drop database if exists ${db_name}_1 """ + order_qt_schemata_4 """ + select * from internal.information_schema.schemata + where CATALOG_NAME = "internal" and SCHEMA_NAME = "${db_name}_1"; + """ + order_qt_schemata_5 """ + select * from internal.information_schema.schemata + where CATALOG_NAME = "internal" and SCHEMA_NAME = "${db_name}_2"; + """ + sql """ drop database if exists ${db_name}_2 """ + order_qt_schemata_6 """ + select * from internal.information_schema.schemata + where CATALOG_NAME = "internal" and SCHEMA_NAME = "${db_name}_1"; + """ + order_qt_schemata_7 """ + select * from internal.information_schema.schemata + where CATALOG_NAME = "internal" and SCHEMA_NAME = "${db_name}_2"; + """ + order_qt_schemata_8 """ + select * from internal.information_schema.schemata + where CATALOG_NAME = "internal" and SCHEMA_NAME = "infomation_schema"; + """ + order_qt_schemata_9 """ + select * from internal.information_schema.schemata + where CATALOG_NAME = "internal" and SCHEMA_NAME = "infomation_schema_ext"; + """ + + sql """ drop database if exists ${db_name}_1 """ + sql """ drop database if exists ${db_name}_2 """ + + //columns + sql """ create database if not exists ${db_name}; """ + sql """ drop table if exists ${db_name}.abcd """ + sql """ + CREATE TABLE ${db_name}.abcd ( + `id` int(11) not null , + `name` string + ) + UNIQUE KEY(`id`) + DISTRIBUTED BY HASH(`id`) BUCKETS 1 + PROPERTIES("replication_num" = "1"); + """ + order_qt_columns_1 """ + select * from internal.information_schema.columns + where TABLE_CATALOG = "internal" and TABLE_SCHEMA = "${db_name}"; + """ + sql """ drop table if exists ${db_name} """ + order_qt_columns_2 """ + select * from internal.information_schema.columns + where TABLE_CATALOG = "internal" and TABLE_SCHEMA = "${db_name}"; + """ + order_qt_columns_3 """ + select * from internal.information_schema.columns + where TABLE_CATALOG = "${catalog_name}" and TABLE_SCHEMA = "tpch1_parquet" and TABLE_NAME = "customer"; + """ + order_qt_columns_4 """ + select * from internal.information_schema.columns + where TABLE_CATALOG = "${catalog_name}" and TABLE_SCHEMA = "tpch1_parquet" and TABLE_NAME = "lineitem"; + """ + order_qt_columns_5 """ + select * from internal.information_schema.columns + where TABLE_CATALOG = "${catalog_name}" and TABLE_SCHEMA = "tpch1_parquet" and TABLE_NAME = "nation"; + """ + order_qt_columns_6 """ + select * from internal.information_schema.columns + where TABLE_CATALOG = "${catalog_name}" and TABLE_SCHEMA = "tpch1_parquet" and TABLE_NAME = "orders"; + """ + order_qt_columns_7 """ + select * from internal.information_schema.columns + where TABLE_CATALOG = "${catalog_name}" and TABLE_SCHEMA = "tpch1_parquet" and TABLE_NAME = "partsupp"; + """ + sql """ drop table if exists ${db_name}.abcd """ + sql """ drop database if exists ${db_name}; """ + + //metadata_name_ids + order_qt_ids_1 """ + select CATALOG_NAME,DATABASE_NAME,TABLE_NAME from internal.information_schema.metadata_name_ids + where CATALOG_NAME = "${catalog_name}" and DATABASE_NAME = "tpch1_parquet" and TABLE_NAME = "customer"; + """ + order_qt_ids_2 """ + select CATALOG_NAME,DATABASE_NAME,TABLE_NAME from internal.information_schema.metadata_name_ids + where CATALOG_NAME = "${catalog_name}" and DATABASE_NAME = "tpch1_parquet" and TABLE_NAME = "lineitem"; + """ + order_qt_ids_3 """ + select CATALOG_NAME,DATABASE_NAME,TABLE_NAME from internal.information_schema.metadata_name_ids + where CATALOG_NAME = "${catalog_name}" and DATABASE_NAME = "tpch1_parquet" and TABLE_NAME = "nation"; + """ + order_qt_ids_4 """ + select CATALOG_NAME,DATABASE_NAME,TABLE_NAME from internal.information_schema.metadata_name_ids + where CATALOG_NAME = "${catalog_name}" and DATABASE_NAME = "tpch1_parquet" and TABLE_NAME = "orders"; + """ + order_qt_ids_5 """ + select CATALOG_NAME,DATABASE_NAME,TABLE_NAME from internal.information_schema.metadata_name_ids + where CATALOG_NAME = "${catalog_name}" and DATABASE_NAME = "tpch1_parquet" and TABLE_NAME = "part"; + """ + order_qt_ids_6 """ + select CATALOG_NAME,DATABASE_NAME,TABLE_NAME from internal.information_schema.metadata_name_ids + where CATALOG_NAME = "${catalog_name}" and DATABASE_NAME = "tpch1_parquet" and TABLE_NAME = "partsupp"; + """ + order_qt_ids_7 """ + select CATALOG_NAME,DATABASE_NAME,TABLE_NAME from internal.information_schema.metadata_name_ids + where CATALOG_NAME = "${catalog_name}" and DATABASE_NAME = "tpch1_parquet" and TABLE_NAME = "region"; + """ + order_qt_ids_8 """ + select CATALOG_NAME,DATABASE_NAME,TABLE_NAME from internal.information_schema.metadata_name_ids + where CATALOG_NAME = "${catalog_name}" and DATABASE_NAME = "tpch1_parquet" and TABLE_NAME = "supplier"; + """ + + //tables + order_qt_tables_1 """ + select TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE,ENGINE,DATA_LENGTH,MAX_DATA_LENGTH,TABLE_COMMENT from internal.information_schema.tables + where TABLE_CATALOG = "${catalog_name}" and TABLE_SCHEMA = "tpch1_parquet" and TABLE_NAME = "supplier"; + """ + order_qt_tables_2 """ + select TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE,ENGINE,DATA_LENGTH,MAX_DATA_LENGTH,TABLE_COMMENT from internal.information_schema.tables + where TABLE_CATALOG = "${catalog_name}" and TABLE_SCHEMA = "tpch1_parquet" and TABLE_NAME = "region"; + """ + order_qt_tables_3 """ + select TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE,ENGINE,DATA_LENGTH,MAX_DATA_LENGTH,TABLE_COMMENT from internal.information_schema.tables + where TABLE_CATALOG = "${catalog_name}" and TABLE_SCHEMA = "tpch1_parquet" and TABLE_NAME = "customer"; + """ + order_qt_tables_4 """ + select TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE,ENGINE,DATA_LENGTH,MAX_DATA_LENGTH,TABLE_COMMENT from internal.information_schema.tables + where TABLE_CATALOG = "${catalog_name}" and TABLE_SCHEMA = "tpch1_parquet" and TABLE_NAME = "lineitem"; + """ + order_qt_tables_5 """ + select TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE,ENGINE,DATA_LENGTH,MAX_DATA_LENGTH,TABLE_COMMENT from internal.information_schema.tables + where TABLE_CATALOG = "${catalog_name}" and TABLE_SCHEMA = "tpch1_parquet" and TABLE_NAME = "nation"; + """ + order_qt_tables_6 """ + select TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE,ENGINE,DATA_LENGTH,MAX_DATA_LENGTH,TABLE_COMMENT from internal.information_schema.tables + where TABLE_CATALOG = "${catalog_name}" and TABLE_SCHEMA = "tpch1_parquet" and TABLE_NAME = "orders"; + """ + order_qt_tables_7 """ + select TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE,ENGINE,DATA_LENGTH,MAX_DATA_LENGTH,TABLE_COMMENT from internal.information_schema.tables + where TABLE_CATALOG = "${catalog_name}" and TABLE_SCHEMA = "tpch1_parquet" and TABLE_NAME = "partsupp"; + """ + + //views + sql """ create database if not exists ${db_name}; """ + sql """ drop table if exists ${db_name}.ab """ + sql """ + CREATE TABLE ${db_name}.ab ( + `id` int(11) not null , + `name` string + ) + UNIQUE KEY(`id`) + DISTRIBUTED BY HASH(`id`) BUCKETS 1 + PROPERTIES("replication_num" = "1"); + """ + sql """ drop VIEW IF EXISTS ${db_name}.test_view """ + sql """ + CREATE VIEW IF NOT EXISTS ${db_name}.test_view (a) + AS + SELECT id as a FROM ${db_name}.ab + """ + order_qt_views_1 """ + select * from internal.information_schema.views + where TABLE_SCHEMA = "${db_name}" and TABLE_NAME = "test_view"; + """ + sql """ drop VIEW IF EXISTS ${db_name}.test_view """ + order_qt_views_2 """ + select * from internal.information_schema.views + where TABLE_SCHEMA = "${db_name}" and TABLE_NAME = "test_view"; + """ + sql """ drop VIEW IF EXISTS ${db_name}.test_view """ + sql """ drop table if exists ${db_name}.ab """ + sql """ drop database if exists ${db_name}; """ + + + + sql """drop catalog if exists ${catalog_name}""" + } finally { + } + } +}