Skip to content

Commit

Permalink
[test](hive catalog)add hive catalog test case (apache#14217)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsy3993 authored Nov 19, 2022
1 parent 2c42f0a commit 5dfe5ef
Show file tree
Hide file tree
Showing 16 changed files with 324 additions and 1 deletion.
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ header:
- "regression-test/suites/load_p0/stream_load/data"
- "docker/thirdparties/docker-compose/hive/scripts/README"
- "docker/thirdparties/docker-compose/hive/scripts/create.hql"
- "docker/thirdparties/docker-compose/hive/scripts/data_case/*/*"

comment: on-failure
148 changes: 148 additions & 0 deletions docker/thirdparties/docker-compose/hive/scripts/create.hql
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,153 @@ LOCATION

msck repair table orc_all_types;

CREATE TABLE `student` (
id varchar(50),
name varchar(50),
age int,
gender varchar(50),
addr varchar(50),
phone varchar(50)
)
ROW FORMAT DELIMITED FIELDS TERMINATED by ','
LOCATION '/user/doris/data_case/student'
TBLPROPERTIES ('transient_lastDdlTime'='1658816839');

CREATE TABLE `lineorder` (
`lo_orderkey` int,
`lo_linenumber` int,
`lo_custkey` int,
`lo_partkey` int,
`lo_suppkey` int,
`lo_orderdate` int,
`lo_orderpriority` varchar(16),
`lo_shippriority` int,
`lo_quantity` int,
`lo_extendedprice` int,
`lo_ordtotalprice` int,
`lo_discount` int,
`lo_revenue` int,
`lo_supplycost` int,
`lo_tax` int,
`lo_commitdate` int,
`lo_shipmode` varchar(11)
)
ROW FORMAT DELIMITED FIELDS TERMINATED by ','
LOCATION '/user/doris/data_case/lineorder'
TBLPROPERTIES ('transient_lastDdlTime'='1658816839');

CREATE TABLE `test1` (
col_1 int,
col_2 varchar(20),
col_3 int,
col_4 int,
col_5 varchar(20)
)
ROW FORMAT DELIMITED FIELDS TERMINATED by ','
LOCATION '/user/doris/data_case/test1'
TBLPROPERTIES ('transient_lastDdlTime'='1658816839');

CREATE TABLE `string_table` (
p_partkey string,
p_name string,
p_mfgr string,
p_brand string,
p_type string,
p_size string,
p_con string,
p_r_price string,
p_comment string
)
ROW FORMAT DELIMITED FIELDS TERMINATED by ','
LOCATION '/user/doris/data_case/string_table'
TBLPROPERTIES ('transient_lastDdlTime'='1658816839');

CREATE TABLE `account_fund` (
`batchno` string,
`appsheet_no` string,
`filedate` string,
`t_no` string,
`tano` string,
`t_name` string,
`chged_no` string,
`mob_no2` string,
`home_no` string,
`off_no` string
)
ROW FORMAT DELIMITED FIELDS TERMINATED by ','
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
'/user/doris/data_case/account_fund'
TBLPROPERTIES ('transient_lastDdlTime'='1658816839');

create table sale_table (
`bill_code` varchar(500),
`dates` varchar(500),
`ord_year` varchar(500),
`ord_month` varchar(500),
`ord_quarter` varchar(500),
`on_time` varchar(500)
)
ROW FORMAT DELIMITED FIELDS TERMINATED by ','
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
LOCATION
'/user/doris/data_case/sale_table'
TBLPROPERTIES ('transient_lastDdlTime'='1658816839');

create table t_hive (
`k1` int,
`k2` char(10),
`k3` date,
`k5` varchar(20),
`k6` double
)
ROW FORMAT DELIMITED FIELDS TERMINATED by ','
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
'/user/doris/data_case/t_hive'
TBLPROPERTIES ('transient_lastDdlTime'='1658816839');

create table hive01 (
first_year int,
d_disease varchar(200),
i_day int,
card_cnt bigint
)
ROW FORMAT DELIMITED FIELDS TERMINATED by ','
LOCATION
'/user/doris/data_case/hive01'
TBLPROPERTIES ('transient_lastDdlTime'='1658816839');

CREATE TABLE test2 (
id int,
name string ,
age string ,
avg_patient_time double,
dt date
)
row format delimited fields terminated by ','
stored as textfile
LOCATION '/user/doris/data_case/test2'
TBLPROPERTIES ('transient_lastDdlTime'='1658816839');

create table test_hive_doris(
id varchar(100),
age varchar(100)
)
row format delimited fields terminated by ','
stored as textfile
LOCATION '/user/doris/data_case/test_hive_doris'
TBLPROPERTIES ('transient_lastDdlTime'='1658816839');


show tables;

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
batchno,appsheet_no,filedate,t_no,tano,t_name,chged_no,mob_no2,home_no,off_no
off_no,home_no,mob_no2,chged_no,t_name,tano,t_no,filedate,appsheet_no,batchno
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1993,newguan,1,12344321
1994,newguan1,2,12344321
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1,2,3,4,5,6,abc,7,8,9,10,11,12,13,14,15,bcd
2,3,4,5,6,7,abc,8,9,10,11,12,13,14,15,16,bcd
3,4,5,6,7,8,abc,9,10,11,12,13,14,15,16,17,bcd
4,5,6,7,8,9,abc,10,11,12,13,14,15,16,17,18,bcd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bill_code,dates,ord_year,ord_month,ord_quarter,on_time
bill_code1,dates2,ord_year3,ord_month4,ord_quarter5,on_time6
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
p_partkey0,p_name0,p_mfgr0,p_brand0,p_type0,p_size0,p_con0,p_r_price0,p_comment0
p_partkey1,p_name1,p_mfgr1,p_brand1,p_type1,p_size1,p_con1,p_r_price1,p_comment1
p_partkey2,p_name2,p_mfgr2,p_brand2,p_type2,p_size2,p_con2,p_r_price2,p_comment2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
123,zhangsan,12,m,abcdefg,13012345678
124,lisi,13,f,abcdefh,13056781234
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
12,k2,2022-01-01,k5,12.3
12,k3,2022-12-31,k6,23.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
123,china,4,56,sc
234,america,5,67,ls
345,cana,4,56,fy
567,fre,7,89,pa
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
123,zhangsan,12,123.45,2022-01-01
124,lisi,12,123.45,2022-01-01
125,lisan,12,123.45,2022-01-02
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
a123,12
a124,13
a125,14
a126,15
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ echo "hadoop fs -put /mnt/scripts/orc /user/doris/"
hadoop fs -put /mnt/scripts/orc /user/doris/
echo "hadoop fs -put /mnt/scripts/csv_format_test /user/doris/"
hadoop fs -put /mnt/scripts/csv_format_test /user/doris/
echo "hadoop fs -put /mnt/scripts/data_case /user/doris/"
hadoop fs -put /mnt/scripts/data_case /user/doris/
echo "hive -f /mnt/scripts/create.hql"
hive -f /mnt/scripts/create.hql

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1091,4 +1091,3 @@ insert into doris_test.ex_tb13 values
('张三7',11,'123445167','123','321312','1998-02-13','中国','',false);



65 changes: 65 additions & 0 deletions regression-test/data/hive_catalog_p0/hive_catalog_case.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !show_tables --
account_fund
customer
hive01
lineitem
lineorder
nation
orc_all_types
orders
part
partition_table
partsupp
region
sale_table
string_table
student
supplier
t_hive
test1
test2
test_hive_doris

-- !q24 --
zhangsan 1
lisi 1

-- !q25 --
1 1
2 1
3 1
4 1

-- !q26 --
123 china 4 56 sc
234 america 5 67 ls
345 cana 4 56 fy
567 fre 7 89 pa

-- !q27 --
p_partkey2 p_name2 p_mfgr2 p_brand2 p_type2 p_size2 p_con2 p_r_price2 p_comment2
p_partkey1 p_name1 p_mfgr1 p_brand1 p_type1 p_size1 p_con1 p_r_price1 p_comment1
p_partkey0 p_name0 p_mfgr0 p_brand0 p_type0 p_size0 p_con0 p_r_price0 p_comment0

-- !q28 --
batchno appsheet_no filedate t_no tano t_name chged_no mob_no2 home_no off_no
off_no home_no mob_no2 chged_no t_name tano t_no filedate appsheet_no batchno

-- !q29 --
bill_code dates ord_year ord_month ord_quarter on_time

-- !q30 --
2

-- !q31 --
123 zhangsan 12 123.45 2022-01-01
124 lisi 12 123.45 2022-01-01
125 lisan 12 123.45 2022-01-02

-- !q32 --
a123 12
a124 13
a125 14
a126 15

80 changes: 80 additions & 0 deletions regression-test/suites/hive_catalog_p0/hive_catalog_case.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// 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("hive_catalog_case", "p0") {

def q01 = {
qt_q24 """ select name, count(1) as c from student group by name order by c desc;"""
qt_q25 """ select lo_orderkey, count(1) as c from lineorder group by lo_orderkey order by c desc;"""
qt_q26 """ select * from test1 order by col_1;"""
qt_q27 """ select * from string_table order by p_partkey desc;"""
qt_q28 """ select * from account_fund order by batchno;"""
qt_q29 """ select * from sale_table order by bill_code limit 01;"""
qt_q30 """ select count(card_cnt) from hive01;"""
qt_q31 """ select * from test2 order by id;"""
qt_q32 """ select * from test_hive_doris order by id;"""
}


def set_be_config = { ->
String[][] backends = sql """ show backends; """
assertTrue(backends.size() > 0)
for (String[] backend in backends) {
// No need to set this config anymore, but leave this code sample here
// StringBuilder setConfigCommand = new StringBuilder();
// setConfigCommand.append("curl -X POST http://")
// setConfigCommand.append(backend[2])
// setConfigCommand.append(":")
// setConfigCommand.append(backend[5])
// setConfigCommand.append("/api/update_config?")
// String command1 = setConfigCommand.toString() + "enable_new_load_scan_node=true"
// logger.info(command1)
// String command2 = setConfigCommand.toString() + "enable_new_file_scanner=true"
// logger.info(command2)
// def process1 = command1.execute()
// int code = process1.waitFor()
// assertEquals(code, 0)
// def process2 = command2.execute()
// code = process1.waitFor()
// assertEquals(code, 0)
}
}

String enabled = context.config.otherConfigs.get("enableHiveTest")
if (enabled != null && enabled.equalsIgnoreCase("true")) {
String hms_port = context.config.otherConfigs.get("hms_port")
set_be_config.call()

sql """admin set frontend config ("enable_multi_catalog" = "true")"""
sql """drop catalog if exists hive"""
sql """
create catalog hive properties (
"type"="hms",
'hive.metastore.uris' = 'thrift://127.0.0.1:${hms_port}'
);
"""
sql """switch hive"""
sql """use `default`"""
order_qt_show_tables """show tables"""

q01()
}
}




0 comments on commit 5dfe5ef

Please sign in to comment.