[test] add bitmap index regression test (#10008)

This commit is contained in:
zy-kkk
2022-06-09 12:19:07 +08:00
committed by GitHub
parent 050cbba6e5
commit 9bc82542fd
5 changed files with 450 additions and 109 deletions

View File

@ -0,0 +1,91 @@
-- 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
default_cluster:regression_test.test_bitmap_index_unique index12 v1 BITMAP
-- !sql --
1 1 1 1 1 1 2022-05-31 2022-05-31T10:00 1 1 true 1

View File

@ -0,0 +1,236 @@
// 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"
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 ${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");
"""
sql """
ALTER TABLE ${tbName1}
ADD INDEX index1 (k1) USING BITMAP,
ADD INDEX index2 (k2) USING BITMAP,
ADD INDEX index3 (k3) USING BITMAP,
ADD INDEX index4 (k4) USING BITMAP,
ADD INDEX index5 (k5) USING BITMAP,
ADD INDEX index6 (k6) USING BITMAP,
ADD INDEX index7 (k7) USING BITMAP,
ADD INDEX index8 (k8) USING BITMAP,
ADD INDEX index9 (k9) USING BITMAP,
ADD INDEX index10 (k10) USING BITMAP,
ADD INDEX index11 (k11) USING BITMAP;
"""
int max_try_secs = 60
while (max_try_secs--) {
String res = getJobState(tbName1)
if (res == "FINISHED") {
break
} else {
Thread.sleep(1000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED", res)
}
}
}
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};"
sql "DROP INDEX IF EXISTS index1 ON ${tbName1};"
max_try_secs = 60
while (max_try_secs--) {
String res = getJobState(tbName1)
if (res == "FINISHED") {
break
} else {
Thread.sleep(1000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED", res)
}
}
}
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");
"""
sql """
ALTER TABLE ${tbName2}
ADD INDEX index1 (k1) USING BITMAP,
ADD INDEX index2 (k2) USING BITMAP,
ADD INDEX index3 (k3) USING BITMAP,
ADD INDEX index4 (k4) USING BITMAP,
ADD INDEX index5 (k5) USING BITMAP,
ADD INDEX index6 (k6) USING BITMAP,
ADD INDEX index7 (k7) USING BITMAP,
ADD INDEX index8 (k8) USING BITMAP,
ADD INDEX index9 (k9) USING BITMAP,
ADD INDEX index10 (k10) USING BITMAP,
ADD INDEX index11 (k11) USING BITMAP;
"""
max_try_secs = 60
while (max_try_secs--) {
String res = getJobState(tbName2)
if (res == "FINISHED") {
break
} else {
Thread.sleep(1000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
}
}
test{
sql "ALTER TABLE ${tbName2} ADD INDEX index12 (v1) USING BITMAP;"
exception "errCode = 2, detailMessage = BITMAP index only used in columns of DUP_KEYS/UNIQUE_KEYS table"
}
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};"
sql "DROP INDEX IF EXISTS index1 ON ${tbName2};"
max_try_secs = 60
while (max_try_secs--) {
String res = getJobState(tbName2)
if (res == "FINISHED") {
break
} else {
Thread.sleep(1000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
}
}
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");
"""
sql """
ALTER TABLE ${tbName3}
ADD INDEX index1 (k1) USING BITMAP,
ADD INDEX index2 (k2) USING BITMAP,
ADD INDEX index3 (k3) USING BITMAP,
ADD INDEX index4 (k4) USING BITMAP,
ADD INDEX index5 (k5) USING BITMAP,
ADD INDEX index6 (k6) USING BITMAP,
ADD INDEX index7 (k7) USING BITMAP,
ADD INDEX index8 (k8) USING BITMAP,
ADD INDEX index9 (k9) USING BITMAP,
ADD INDEX index10 (k10) USING BITMAP,
ADD INDEX index11 (k11) USING BITMAP,
ADD INDEX index12 (v1) USING BITMAP;
"""
max_try_secs = 60
while (max_try_secs--) {
String res = getJobState(tbName3)
if (res == "FINISHED") {
break
} else {
Thread.sleep(1000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
}
}
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};"
sql "DROP INDEX IF EXISTS index1 ON ${tbName3};"
max_try_secs = 60
while (max_try_secs--) {
String res = getJobState(tbName3)
if (res == "FINISHED") {
break
} else {
Thread.sleep(1000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
}
}
sql "DROP TABLE ${tbName3};"
}

View File

@ -17,6 +17,11 @@
suite("test_materialized_view", "rollup") {
def tbName1 = "test_materialized_view1"
def tbName2 = "test_materialized_view2"
def getJobState = { tableName ->
def jobStateResult = sql """ SHOW ALTER TABLE MATERIALIZED VIEW WHERE TableName='${tableName}' ORDER BY CreateTime DESC LIMIT 1; """
return jobStateResult[0][8]
}
sql "DROP TABLE IF EXISTS ${tbName1}"
sql """
CREATE TABLE ${tbName1}(
@ -40,24 +45,32 @@ suite("test_materialized_view", "rollup") {
DISTRIBUTED BY HASH(record_id) properties("replication_num" = "1");
"""
sql "CREATE materialized VIEW amt_sum AS SELECT store_id, sum(sale_amt) FROM ${tbName1} GROUP BY store_id;"
String res = "null"
while (!res.contains("FINISHED")){
res = sql "SHOW ALTER TABLE MATERIALIZED VIEW WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;"
if(res.contains("CANCELLED")){
print("job is cancelled")
int max_try_secs = 60
while (max_try_secs--) {
String res = getJobState(tbName1)
if (res == "FINISHED") {
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
}
Thread.sleep(1000)
}
sql "CREATE materialized VIEW seller_id_order AS SELECT store_id,seller_id, sale_amt FROM ${tbName2} ORDER BY store_id,seller_id;"
res = "null"
while (!res.contains("FINISHED")){
res = sql "SHOW ALTER TABLE MATERIALIZED VIEW WHERE TableName='${tbName2}' ORDER BY CreateTime DESC LIMIT 1;"
if(res.contains("CANCELLED")){
print("job is cancelled")
max_try_secs = 60
while (max_try_secs--) {
String res = getJobState(tbName2)
if (res == "FINISHED") {
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
}
Thread.sleep(1000)
}
sql "SHOW ALTER TABLE MATERIALIZED VIEW WHERE TableName='${tbName1}';"
sql "SHOW ALTER TABLE MATERIALIZED VIEW WHERE TableName='${tbName2}';"
@ -67,7 +80,7 @@ suite("test_materialized_view", "rollup") {
sql "insert into ${tbName1} values(2, 1, 1, '2020-05-30',100);"
sql "insert into ${tbName2} values(1, 1, 1, '2020-05-30',100);"
sql "insert into ${tbName2} values(2, 1, 1, '2020-05-30',100);"
Thread.sleep(5000)
Thread.sleep(1000)
explain{
sql("SELECT store_id, sum(sale_amt) FROM ${tbName1} GROUP BY store_id")
contains("rollup: amt_sum")
@ -77,18 +90,21 @@ suite("test_materialized_view", "rollup") {
qt_sql "SELECT * FROM ${tbName2} order by record_id;"
qt_sql "SELECT store_id, sum(sale_amt) FROM ${tbName2} GROUP BY store_id order by store_id;"
sql "CREATE materialized VIEW amt_count AS SELECT store_id, count(sale_amt) FROM ${tbName1} GROUP BY store_id;"
res = "null"
while (!res.contains("FINISHED") || !res.contains("amt_count")){
res = sql "SHOW ALTER TABLE MATERIALIZED VIEW WHERE TableName='${tbName1}' ORDER BY CreateTime DESC LIMIT 1;"
if(res.contains("CANCELLED")){
print("job is cancelled")
max_try_secs = 60
while (max_try_secs--) {
String res = getJobState(tbName1)
if (res == "FINISHED") {
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
}
Thread.sleep(1000)
}
sql "SELECT store_id, count(sale_amt) FROM ${tbName1} t GROUP BY store_id;"
sql "SELECT store_id, count(sale_amt) FROM ${tbName1} GROUP BY store_id;"
sql "DROP TABLE ${tbName1}"
sql "DROP TABLE ${tbName2}"

View File

@ -16,6 +16,15 @@
// under the License.
suite("test_rollup_agg", "rollup") {
def tbName = "test_rollup_agg"
def getJobRollupState = { tableName ->
def jobStateResult = sql """ SHOW ALTER TABLE ROLLUP WHERE TableName='${tableName}' ORDER BY CreateTime DESC LIMIT 1; """
return jobStateResult[0][8]
}
def getJobColumnState = { 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 IF NOT EXISTS ${tbName}(
@ -28,31 +37,39 @@ suite("test_rollup_agg", "rollup") {
AGGREGATE KEY (siteid,citycode,username)
DISTRIBUTED BY HASH(siteid) BUCKETS 5 properties("replication_num" = "1");
"""
String res = "null"
sql "ALTER TABLE ${tbName} ADD ROLLUP rollup_city(citycode, pv);"
while (!res.contains("FINISHED")){
res = sql "SHOW ALTER TABLE ROLLUP WHERE TableName='${tbName}' ORDER BY CreateTime DESC LIMIT 1;"
if(res.contains("CANCELLED")){
print("job is cancelled")
sql """ALTER TABLE ${tbName} ADD ROLLUP rollup_city(citycode, pv);"""
int max_try_secs = 60
while (max_try_secs--) {
String res = getJobRollupState(tbName)
if (res == "FINISHED") {
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
}
Thread.sleep(1000)
}
res = "null"
sql "ALTER TABLE ${tbName} ADD COLUMN vv BIGINT SUM NULL DEFAULT '0' TO rollup_city;"
while (!res.contains("FINISHED")){
res = sql "SHOW ALTER TABLE COLUMN WHERE TableName='${tbName}' ORDER BY CreateTime DESC LIMIT 1;"
if(res.contains("CANCELLED")){
print("job is cancelled")
max_try_secs = 60
while (max_try_secs--) {
String res = getJobColumnState(tbName)
if (res == "FINISHED") {
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
}
Thread.sleep(1000)
}
sql "SHOW ALTER TABLE ROLLUP WHERE TableName='${tbName}';"
qt_sql "DESC ${tbName} ALL;"
sql "insert into ${tbName} values(1, 1, 'test1', 100,100,100);"
sql "insert into ${tbName} values(2, 1, 'test2', 100,100,100);"
explain{
explain {
sql("SELECT citycode,SUM(pv) FROM ${tbName} GROUP BY citycode")
contains("rollup: rollup_city")
}

View File

@ -17,6 +17,11 @@
suite("test_alter_table_column", "schema_change") {
def tbName1 = "alter_table_column_dup"
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 ${tbName1}"
sql """
CREATE TABLE IF NOT EXISTS ${tbName1} (
@ -26,67 +31,46 @@ suite("test_alter_table_column", "schema_change") {
DUPLICATE KEY (k1)
DISTRIBUTED BY HASH(k1) BUCKETS 5 properties("replication_num" = "1");
"""
String res = "null"
sql "ALTER TABLE ${tbName1} ADD COLUMN k2 INT KEY AFTER k1"
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")
sql """
ALTER TABLE ${tbName1}
ADD COLUMN k2 INT KEY AFTER k1,
ADD COLUMN value2 VARCHAR(255) AFTER value1,
ADD COLUMN value3 VARCHAR(255) AFTER value2,
MODIFY COLUMN value2 INT AFTER value3;
"""
int max_try_secs = 60
while (max_try_secs--) {
String res = getJobState(tbName1)
if (res == "FINISHED") {
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
}
Thread.sleep(1000)
}
res = "null"
sql "ALTER TABLE ${tbName1} ADD COLUMN value2 VARCHAR(255) AFTER value1"
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")
sql """
ALTER TABLE ${tbName1}
ORDER BY(k1,k2,value1,value2,value3),
DROP COLUMN value3;
"""
max_try_secs = 60
while (max_try_secs--) {
String res = getJobState(tbName1)
if (res == "FINISHED") {
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
}
Thread.sleep(1000)
}
res = "null"
sql "ALTER TABLE ${tbName1} ADD COLUMN value3 VARCHAR(255) AFTER value2"
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 "ALTER TABLE ${tbName1} MODIFY COLUMN value2 INT AFTER value3;"
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 "ALTER TABLE ${tbName1} ORDER BY(k1,k2,value1,value2,value3);"
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 "ALTER TABLE ${tbName1} DROP COLUMN value3;"
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 "SHOW ALTER TABLE COLUMN"
sql "SHOW ALTER TABLE COLUMN;"
sql "insert into ${tbName1} values(1,1,10,20);"
sql "insert into ${tbName1} values(1,1,30,40);"
qt_sql "desc ${tbName1}"
@ -103,26 +87,25 @@ suite("test_alter_table_column", "schema_change") {
AGGREGATE KEY (k1)
DISTRIBUTED BY HASH(k1) BUCKETS 5 properties("replication_num" = "1");
"""
sql "ALTER TABLE ${tbName2} ADD COLUMN k2 INT KEY AFTER k1"
res = "null"
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")
sql """
ALTER TABLE ${tbName2}
ADD COLUMN k2 INT KEY AFTER k1,
ADD COLUMN value2 INT SUM AFTER value1;
"""
max_try_secs = 60
while (max_try_secs--) {
String res = getJobState(tbName2)
if (res == "FINISHED") {
break
} else {
Thread.sleep(2000)
if (max_try_secs < 1) {
println "test timeout," + "state:" + res
assertEquals("FINISHED",res)
}
}
Thread.sleep(1000)
}
res = "null"
sql "ALTER TABLE ${tbName2} ADD COLUMN value2 INT SUM AFTER value1"
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 "SHOW ALTER TABLE COLUMN"
sql "insert into ${tbName2} values(1,1,10,20);"
sql "insert into ${tbName2} values(1,1,30,40);"
@ -130,5 +113,3 @@ suite("test_alter_table_column", "schema_change") {
qt_sql "select * from ${tbName2}"
sql "DROP TABLE ${tbName2}"
}