From ec5027a00a2ba66f04876947ccbc17dfc09dd56a Mon Sep 17 00:00:00 2001 From: zy-kkk <815574403@qq.com> Date: Tue, 31 May 2022 19:18:43 +0800 Subject: [PATCH] [regressiontest]add bitmap index test case (#9880) --- .../data/index/test_bitmap_index.out | 90 ++++ .../suites/index/test_bitmap_index.groovy | 454 ++++++++++++++++++ 2 files changed, 544 insertions(+) create mode 100644 regression-test/data/index/test_bitmap_index.out create mode 100644 regression-test/suites/index/test_bitmap_index.groovy diff --git a/regression-test/data/index/test_bitmap_index.out b/regression-test/data/index/test_bitmap_index.out new file mode 100644 index 0000000000..9c537f6bd8 --- /dev/null +++ b/regression-test/data/index/test_bitmap_index.out @@ -0,0 +1,90 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !sql -- +k1 TINYINT Yes true \N +k2 SMALLINT Yes true \N +k3 INT Yes true \N +k4 BIGINT Yes false \N NONE +k5 CHAR(1) Yes false \N NONE +k6 VARCHAR(1) Yes false \N NONE +k7 DATE Yes false \N NONE +k8 DATETIME Yes false \N NONE +k9 LARGEINT Yes false \N NONE +k10 DECIMAL(9,0) Yes false \N NONE +k11 BOOLEAN Yes false \N NONE + +-- !sql -- +default_cluster:regression_test.test_bitmap_index_dup index1 k1 BITMAP +default_cluster:regression_test.test_bitmap_index_dup index2 k2 BITMAP +default_cluster:regression_test.test_bitmap_index_dup index3 k3 BITMAP +default_cluster:regression_test.test_bitmap_index_dup index4 k4 BITMAP +default_cluster:regression_test.test_bitmap_index_dup index5 k5 BITMAP +default_cluster:regression_test.test_bitmap_index_dup index6 k6 BITMAP +default_cluster:regression_test.test_bitmap_index_dup index7 k7 BITMAP +default_cluster:regression_test.test_bitmap_index_dup index8 k8 BITMAP +default_cluster:regression_test.test_bitmap_index_dup index9 k9 BITMAP +default_cluster:regression_test.test_bitmap_index_dup index10 k10 BITMAP +default_cluster:regression_test.test_bitmap_index_dup index11 k11 BITMAP + +-- !sql -- +1 1 1 1 1 1 2022-05-31 2022-05-31T10:00 1 1 true + +-- !sql -- +k1 TINYINT Yes true \N +k2 SMALLINT Yes true \N +k3 INT Yes true \N +k4 BIGINT Yes true \N +k5 CHAR(1) Yes true \N +k6 VARCHAR(1) Yes true \N +k7 DATE Yes true \N +k8 DATETIME Yes true \N +k9 LARGEINT Yes true \N +k10 DECIMAL(9,0) Yes true \N +k11 BOOLEAN Yes true \N +v1 INT Yes false \N SUM + +-- !sql -- +default_cluster:regression_test.test_bitmap_index_agg index1 k1 BITMAP +default_cluster:regression_test.test_bitmap_index_agg index2 k2 BITMAP +default_cluster:regression_test.test_bitmap_index_agg index3 k3 BITMAP +default_cluster:regression_test.test_bitmap_index_agg index4 k4 BITMAP +default_cluster:regression_test.test_bitmap_index_agg index5 k5 BITMAP +default_cluster:regression_test.test_bitmap_index_agg index6 k6 BITMAP +default_cluster:regression_test.test_bitmap_index_agg index7 k7 BITMAP +default_cluster:regression_test.test_bitmap_index_agg index8 k8 BITMAP +default_cluster:regression_test.test_bitmap_index_agg index9 k9 BITMAP +default_cluster:regression_test.test_bitmap_index_agg index10 k10 BITMAP +default_cluster:regression_test.test_bitmap_index_agg index11 k11 BITMAP + +-- !sql -- +1 1 1 1 1 1 2022-05-31 2022-05-31T10:00 1 1 true 1 + +-- !sql -- +k1 TINYINT Yes true \N +k2 SMALLINT Yes true \N +k3 INT Yes true \N +k4 BIGINT Yes true \N +k5 CHAR(1) Yes true \N +k6 VARCHAR(1) Yes true \N +k7 DATE Yes true \N +k8 DATETIME Yes true \N +k9 LARGEINT Yes true \N +k10 DECIMAL(9,0) Yes true \N +k11 BOOLEAN Yes true \N +v1 INT Yes false \N REPLACE + +-- !sql -- +default_cluster:regression_test.test_bitmap_index_unique index1 k1 BITMAP +default_cluster:regression_test.test_bitmap_index_unique index2 k2 BITMAP +default_cluster:regression_test.test_bitmap_index_unique index3 k3 BITMAP +default_cluster:regression_test.test_bitmap_index_unique index4 k4 BITMAP +default_cluster:regression_test.test_bitmap_index_unique index5 k5 BITMAP +default_cluster:regression_test.test_bitmap_index_unique index6 k6 BITMAP +default_cluster:regression_test.test_bitmap_index_unique index7 k7 BITMAP +default_cluster:regression_test.test_bitmap_index_unique index8 k8 BITMAP +default_cluster:regression_test.test_bitmap_index_unique index9 k9 BITMAP +default_cluster:regression_test.test_bitmap_index_unique index10 k10 BITMAP +default_cluster:regression_test.test_bitmap_index_unique index11 k11 BITMAP + +-- !sql -- +1 1 1 1 1 1 2022-05-31 2022-05-31T10:00 1 1 true 1 + diff --git a/regression-test/suites/index/test_bitmap_index.groovy b/regression-test/suites/index/test_bitmap_index.groovy new file mode 100644 index 0000000000..93ff6947d2 --- /dev/null +++ b/regression-test/suites/index/test_bitmap_index.groovy @@ -0,0 +1,454 @@ +// 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_index", "index") { + def tbName1 = "test_bitmap_index_dup" + sql "DROP TABLE IF EXISTS ${tbName1}" + sql """ + CREATE TABLE IF NOT EXISTS ${tbName1} ( + k1 TINYINT, + k2 SMALLINT, + k3 INT, + k4 BIGINT, + k5 CHAR, + k6 VARCHAR, + k7 DATE, + k8 DATETIME, + k9 LARGEINT, + k10 DECIMAL, + k11 BOOLEAN + ) + DISTRIBUTED BY HASH(k1) BUCKETS 5 properties("replication_num" = "1"); + """ + String res = "null" + sql "CREATE INDEX IF NOT EXISTS index1 ON ${tbName1} (k1) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index2 ON ${tbName1} (k2) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index3 ON ${tbName1} (k3) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index4 ON ${tbName1} (k4) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index5 ON ${tbName1} (k5) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index6 ON ${tbName1} (k6) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index7 ON ${tbName1} (k7) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index8 ON ${tbName1} (k8) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index9 ON ${tbName1} (k9) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index10 ON ${tbName1} (k10) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index11 ON ${tbName1} (k11) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + sql "insert into ${tbName1} values(1,1,1,1,'1','1','2022-05-31','2022-05-31 10:00:00',1,1.0,1);" + qt_sql "desc ${tbName1};" + qt_sql "SHOW INDEX FROM ${tbName1};" + qt_sql "select * from ${tbName1};" + res = "null" + sql "DROP INDEX IF EXISTS index1 ON ${tbName1};" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + sql "DROP TABLE ${tbName1};" + + def tbName2 = "test_bitmap_index_agg" + sql "DROP TABLE IF EXISTS ${tbName2}" + sql """ + CREATE TABLE IF NOT EXISTS ${tbName2} ( + k1 TINYINT, + k2 SMALLINT, + k3 INT, + k4 BIGINT, + k5 CHAR, + k6 VARCHAR, + k7 DATE, + k8 DATETIME, + k9 LARGEINT, + k10 DECIMAL, + k11 BOOLEAN, + v1 INT SUM + ) + AGGREGATE KEY(k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11) + DISTRIBUTED BY HASH(k1) BUCKETS 5 properties("replication_num" = "1"); + """ + res = "null" + sql "CREATE INDEX IF NOT EXISTS index1 ON ${tbName2} (k1) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName2}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index2 ON ${tbName2} (k2) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName2}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index3 ON ${tbName2} (k3) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName2}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index4 ON ${tbName2} (k4) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName2}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index5 ON ${tbName2} (k5) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName2}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index6 ON ${tbName2} (k6) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName2}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index7 ON ${tbName2} (k7) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName2}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index8 ON ${tbName2} (k8) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName2}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index9 ON ${tbName2} (k9) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName2}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index10 ON ${tbName2} (k10) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName2}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index11 ON ${tbName2} (k11) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName2}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + sql "insert into ${tbName2} values(1,1,1,1,'1','1','2022-05-31','2022-05-31 10:00:00',1,1.0,1,1);" + qt_sql "desc ${tbName2};" + qt_sql "SHOW INDEX FROM ${tbName2};" + qt_sql "select * from ${tbName2};" + res = "null" + sql "DROP INDEX IF EXISTS index1 ON ${tbName2};" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName2}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + sql "DROP TABLE ${tbName2};" + + def tbName3 = "test_bitmap_index_unique" + sql "DROP TABLE IF EXISTS ${tbName3}" + sql """ + CREATE TABLE IF NOT EXISTS ${tbName3} ( + k1 TINYINT, + k2 SMALLINT, + k3 INT, + k4 BIGINT, + k5 CHAR, + k6 VARCHAR, + k7 DATE, + k8 DATETIME, + k9 LARGEINT, + k10 DECIMAL, + k11 BOOLEAN, + v1 INT + ) + UNIQUE KEY(k1,k2,k3,k4,k5,k6,k7,k8,k9,k10,k11) + DISTRIBUTED BY HASH(k1) BUCKETS 5 properties("replication_num" = "1"); + """ + res = "null" + sql "CREATE INDEX IF NOT EXISTS index1 ON ${tbName3} (k1) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName3}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index2 ON ${tbName3} (k2) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName3}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index3 ON ${tbName3} (k3) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName3}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index4 ON ${tbName3} (k4) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName3}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index5 ON ${tbName3} (k5) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName3}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index6 ON ${tbName3} (k6) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName3}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index7 ON ${tbName3} (k7) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName3}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index8 ON ${tbName3} (k8) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName3}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index9 ON ${tbName3} (k9) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName3}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index10 ON ${tbName3} (k10) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName3}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + res = "null" + sql "CREATE INDEX IF NOT EXISTS index11 ON ${tbName3} (k11) USING BITMAP;" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName3}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + sql "insert into ${tbName3} values(1,1,1,1,'1','1','2022-05-31','2022-05-31 10:00:00',1,1.0,1,1);" + qt_sql "desc ${tbName3};" + qt_sql "SHOW INDEX FROM ${tbName3};" + qt_sql "select * from ${tbName3};" + res = "null" + sql "DROP INDEX IF EXISTS index1 ON ${tbName3};" + while (!res.contains("FINISHED")){ + res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName3}' ORDER BY CreateTime DESC LIMIT 1;" + if(res.contains("CANCELLED")){ + print("job is cancelled") + break + } + Thread.sleep(1000) + } + sql "DROP TABLE ${tbName3};" +} +