[test] Add bitmap_intersect and schema_change test for regression test. (#9854)

This commit is contained in:
Hong Liu
2022-06-20 09:51:31 +08:00
committed by GitHub
parent 588634ddf6
commit acf07d8966
4 changed files with 158 additions and 1 deletions

View File

@ -0,0 +1,13 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
1,2
-- !sql --
-- !sql --
1,2
-- !sql --

View File

@ -0,0 +1,14 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !desc_uniq_table --
event_day DATE Yes true \N
siteid INT Yes true 10
citycode TEXT Yes false \N REPLACE
username VARCHAR(32) Yes false REPLACE
pv BIGINT Yes false 0 REPLACE
-- !sql --
2021-11-01 1 1 用户A 3
2021-11-02 1 1 用户B 1
2021-11-02 101 112332121 用户B 112312
2021-11-02 103 112332211 用户B 112312

View File

@ -0,0 +1,87 @@
// 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_bitmap_intersect", "bitmap_function") {
def tbName = "test_bitmap_intersect"
sql """ SET enable_vectorized_engine = FALSE; """
sql """ DROP TABLE IF EXISTS ${tbName} """
sql """ create table ${tbName} (tag varchar(20),user_ids bitmap bitmap_union) aggregate key (tag) distributed by hash (tag) PROPERTIES("replication_num" = "1"); """
sql """ insert into ${tbName} values('A', to_bitmap(1)); """
sql """ insert into ${tbName} values('A', to_bitmap(2)); """
sql """ insert into ${tbName} values('A', to_bitmap(3)); """
sql """ insert into ${tbName} values('B', to_bitmap(1)); """
sql """ insert into ${tbName} values('B', to_bitmap(2)); """
qt_sql """ select
bitmap_to_string(bitmap_intersect(user_ids))
from
(
select
tag,
bitmap_union(user_ids) user_ids
from
${tbName}
group by
tag
) t
"""
qt_sql """ select
bitmap_to_string(bitmap_intersect(user_ids))
from
(
select
tag,
bitmap_union(user_ids) user_ids
from
${tbName}
group by
tag having tag not in ("A","B")
) t
"""
sql """ SET enable_vectorized_engine = true; """
qt_sql """ select
bitmap_to_string(bitmap_intersect(user_ids))
from
(
select
tag,
bitmap_union(user_ids) user_ids
from
${tbName}
group by
tag
) t
"""
qt_sql """ select
bitmap_to_string(bitmap_intersect(user_ids))
from
(
select
tag,
bitmap_union(user_ids) user_ids
from
${tbName}
group by
tag having tag not in ("A","B")
) t
"""
sql """ DROP TABLE ${tbName} """
}

View File

@ -17,5 +17,48 @@
suite("test_schema_change", "schema_change") {
// todo: test alter table schema change, such as add/drop/modify/order column
sql "show alter table column"
def tbName = "alter_table_column_type"
def getJobState = { tableName ->
def jobStateResult = sql """ SHOW ALTER TABLE COLUMN WHERE TableName='${tableName}' ORDER BY createtime DESC LIMIT 1 """
return jobStateResult[0][9]
}
sql """ DROP TABLE IF EXISTS ${tbName} """
sql """
CREATE TABLE ${tbName}
(
event_day DATE,
siteid INT DEFAULT '10',
citycode bigint,
username VARCHAR(32) DEFAULT '',
pv BIGINT DEFAULT '0'
)
UNIQUE KEY(event_day,siteid)
PARTITION BY RANGE(event_day)
(
PARTITION p201706 VALUES LESS THAN ('2021-11-01'),
PARTITION p201707 VALUES LESS THAN ('2021-12-01')
)
DISTRIBUTED BY HASH(siteid) BUCKETS 5
PROPERTIES("replication_num" = "1");
"""
sql """ insert into ${tbName} values('2021-11-01',1,1,'用户A',1),('2021-11-01',1,1,'用户B',1),('2021-11-01',1,1,'用户A',3),('2021-11-02',1,1,'用户A',1),('2021-11-02',1,1,'用户B',1),('2021-11-02',101,112332121,'用户B',112312),('2021-11-02',103,112332211,'用户B',112312); """
sql """ alter table ${tbName} modify column citycode string """
int max_try_time = 100
while(max_try_time--){
String result = getJobState(tbName)
if (result == "FINISHED") {
qt_desc_uniq_table """ desc ${tbName} """
qt_sql """ SELECT * FROM ${tbName} order by event_day,citycode """
sql """ DROP TABLE ${tbName} """
break
} else {
sleep(1000)
if (max_try_time < 1){
assertEquals(1,2)
}
}
}
}