forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test](regression) Add more alter stmt regression case (apache#26988)
- Loading branch information
1 parent
f5f4a73
commit f16d4c5
Showing
10 changed files
with
794 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
regression-test/data/schema_change_p0/test_alter_parition.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select -- | ||
1 2017-01-01 Beijing 10 1 1 30 20 \N \N | ||
2 2017-02-01 Beijing 10 1 1 31 19 \N \N | ||
3 2017-03-01 Beijing 10 1 1 31 21 \N \N | ||
|
40 changes: 40 additions & 0 deletions
40
regression-test/data/schema_change_p0/test_alter_table_add_columns.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !order -- | ||
1 1 xxx 1 | ||
2 2 xxx 2 | ||
3 3 xxx 3 | ||
|
||
-- !order -- | ||
1 1 xxx 1 1 2 | ||
2 2 xxx 2 1 2 | ||
3 3 xxx 3 1 2 | ||
|
||
-- !order -- | ||
1 1 xxx 1 1 2 | ||
2 2 xxx 2 1 2 | ||
3 3 xxx 3 1 2 | ||
4 4 yyy 4 4 4 | ||
5 5 yyy 5 5 5 | ||
6 6 yyy 6 6 6 | ||
|
||
-- !sql -- | ||
siteid INT Yes true 10 | ||
citycode SMALLINT Yes true \N | ||
username VARCHAR(32) Yes true test | ||
new_k1 INT Yes true 1 | ||
new_k2 INT Yes true 2 | ||
pv BIGINT Yes false 0 SUM | ||
new_v1 INT Yes false 1 MAX | ||
new_v2 INT Yes false 2 MAX | ||
|
||
-- !order -- | ||
1 1 xxx 1 2 1 1 2 | ||
2 2 xxx 1 2 2 1 2 | ||
3 3 xxx 1 2 3 1 2 | ||
4 4 yyy 1 2 4 4 4 | ||
5 5 yyy 1 2 5 5 5 | ||
6 6 yyy 1 2 6 6 6 | ||
7 7 zzz 7 7 7 7 7 | ||
8 8 zzz 8 8 8 8 8 | ||
9 9 zzz 9 9 9 9 9 | ||
|
41 changes: 41 additions & 0 deletions
41
regression-test/data/schema_change_p0/test_alter_table_drop_column.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !order -- | ||
1 1 xxx 1 | ||
2 2 xxx 2 | ||
3 3 xxx 3 | ||
|
||
-- !order -- | ||
1 1 xxx 1 | ||
2 2 xxx 2 | ||
3 3 xxx 3 | ||
|
||
-- !order -- | ||
1 1 xxx 1 | ||
2 2 xxx 2 | ||
3 3 xxx 3 | ||
|
||
-- !order -- | ||
1 1 xxx 1 | ||
2 2 xxx 2 | ||
3 3 xxx 3 | ||
|
||
-- !order -- | ||
1 1 xxx 1 | ||
2 2 xxx 2 | ||
3 3 xxx 3 | ||
|
||
-- !order -- | ||
1 1 xxx 1 | ||
2 2 xxx 2 | ||
3 3 xxx 3 | ||
|
||
-- !order -- | ||
1 1 xxx 1 | ||
2 2 xxx 2 | ||
3 3 xxx 3 | ||
|
||
-- !order -- | ||
1 1 xxx 1 | ||
2 2 xxx 2 | ||
3 3 xxx 3 | ||
|
29 changes: 29 additions & 0 deletions
29
regression-test/data/schema_change_p0/test_alter_table_modify_column.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !order -- | ||
1 1 xxx 1 | ||
2 2 xxx 2 | ||
3 3 xxx 3 | ||
|
||
-- !order -- | ||
1 1 xxx 1 | ||
2 2 xxx 2 | ||
3 3 xxx 3 | ||
|
||
-- !order -- | ||
1 1 xxx 1 | ||
2 2 xxx 2 | ||
3 3 xxx 3 | ||
|
||
-- !order -- | ||
xxx 1 1 1 | ||
xxx 2 2 2 | ||
xxx 3 3 3 | ||
yyy 4 4 4 | ||
|
||
-- !order -- | ||
1 1 xxx 1 | ||
2 2 xxx 2 | ||
3 3 xxx 3 | ||
4 4 yyy 4 | ||
5 5 zzz 5 | ||
|
26 changes: 26 additions & 0 deletions
26
regression-test/data/schema_change_p0/test_alter_table_replace.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select -- | ||
1 2017-01-01 Beijing 10 1 1 30 20 \N \N | ||
2 2017-02-01 Beijing 10 1 1 31 19 \N \N | ||
3 2017-03-01 Beijing 10 1 1 31 21 \N \N | ||
|
||
-- !select -- | ||
4 2017-01-01 Beijing 10 1 1 30 20 \N \N | ||
5 2017-02-01 Beijing 10 1 1 31 19 \N \N | ||
6 2017-03-01 Beijing 10 1 1 31 21 \N \N | ||
|
||
-- !select -- | ||
4 2017-01-01 Beijing 10 1 1 30 20 \N \N | ||
5 2017-02-01 Beijing 10 1 1 31 19 \N \N | ||
6 2017-03-01 Beijing 10 1 1 31 21 \N \N | ||
|
||
-- !select -- | ||
1 2017-01-01 Beijing 10 1 1 30 20 \N \N | ||
2 2017-02-01 Beijing 10 1 1 31 19 \N \N | ||
3 2017-03-01 Beijing 10 1 1 31 21 \N \N | ||
|
||
-- !select -- | ||
1 2017-01-01 Beijing 10 1 1 30 20 \N \N | ||
2 2017-02-01 Beijing 10 1 1 31 19 \N \N | ||
3 2017-03-01 Beijing 10 1 1 31 21 \N \N | ||
|
65 changes: 65 additions & 0 deletions
65
regression-test/suites/schema_change_p0/test_alter_parition.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// 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_alter_partition") { | ||
def tbName = "test_alter_partition" | ||
|
||
sql "DROP TABLE IF EXISTS ${tbName} FORCE" | ||
sql """ | ||
CREATE TABLE ${tbName} ( | ||
`user_id` LARGEINT NOT NULL COMMENT "用户id", | ||
`date` DATE NOT NULL COMMENT "数据灌入日期时间", | ||
`city` VARCHAR(20) COMMENT "用户所在城市", | ||
`age` SMALLINT COMMENT "用户年龄", | ||
`sex` TINYINT COMMENT "用户性别", | ||
`cost` BIGINT SUM DEFAULT "0" COMMENT "用户总消费", | ||
`max_dwell_time` INT MAX DEFAULT "0" COMMENT "用户最大停留时间", | ||
`min_dwell_time` INT MIN DEFAULT "99999" COMMENT "用户最小停留时间", | ||
`hll_col` HLL HLL_UNION NOT NULL COMMENT "HLL列", | ||
`bitmap_col` Bitmap BITMAP_UNION NOT NULL COMMENT "bitmap列") | ||
AGGREGATE KEY(`user_id`, `date`, `city`, `age`, `sex`) | ||
PARTITION BY RANGE(`date`) | ||
( | ||
PARTITION `p201701` VALUES LESS THAN ("2017-02-01"), | ||
PARTITION `p201702` VALUES LESS THAN ("2017-03-01"), | ||
PARTITION `p201703` VALUES LESS THAN ("2017-04-01") | ||
) | ||
DISTRIBUTED BY HASH(`user_id`) | ||
BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_num" = "1" | ||
); | ||
; | ||
""" | ||
|
||
sql """ INSERT INTO ${tbName} VALUES | ||
(1, '2017-01-01', 'Beijing', 10, 1, 1, 30, 20, hll_hash(1), to_bitmap(1)), | ||
(2, '2017-02-01', 'Beijing', 10, 1, 1, 31, 19, hll_hash(2), to_bitmap(2)), | ||
(3, '2017-03-01', 'Beijing', 10, 1, 1, 31, 21, hll_hash(2), to_bitmap(2)) | ||
""" | ||
|
||
qt_select """ select * from ${tbName} order by user_id""" | ||
|
||
// modify in_memory property | ||
// https://github.com/apache/doris/pull/18731 | ||
test { | ||
sql """ALTER TABLE ${tbName} MODIFY PARTITION p201701 SET ("in_memory" = "true");""" | ||
exception "Not support set 'in_memory'='true' now!" | ||
} | ||
sql "DROP TABLE IF EXISTS ${tbName} FORCE" | ||
} |
88 changes: 88 additions & 0 deletions
88
regression-test/suites/schema_change_p0/test_alter_table_add_columns.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// 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_alter_table_add_columns") { | ||
def tbName = "test_alter_table_add_columns" | ||
|
||
sql "DROP TABLE IF EXISTS ${tbName} FORCE" | ||
sql """ | ||
CREATE TABLE `${tbName}` | ||
( | ||
`siteid` INT DEFAULT '10', | ||
`citycode` SMALLINT, | ||
`username` VARCHAR(32) DEFAULT 'test', | ||
`pv` BIGINT SUM DEFAULT '0' | ||
) | ||
AGGREGATE KEY(`siteid`, `citycode`, `username`) | ||
DISTRIBUTED BY HASH(siteid) BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_num" = "1" | ||
); | ||
""" | ||
|
||
sql """ INSERT INTO ${tbName} VALUES | ||
(1, 1, "xxx", 1), | ||
(2, 2, "xxx", 2), | ||
(3, 3, "xxx", 3); | ||
""" | ||
|
||
qt_order """ select * from ${tbName} order by siteid""" | ||
|
||
// Add two value column light schema change is true | ||
sql """ alter table ${tbName} ADD COLUMN (new_v1 INT MAX default "1" , new_v2 INT MAX default "2");""" | ||
|
||
qt_order """ select * from ${tbName} order by siteid""" | ||
|
||
sql """ INSERT INTO ${tbName} VALUES | ||
(4, 4, "yyy", 4, 4, 4), | ||
(5, 5, "yyy", 5, 5, 5), | ||
(6, 6, "yyy", 6, 6, 6); | ||
""" | ||
|
||
qt_order """ select * from ${tbName} order by siteid""" | ||
|
||
// Add one value column light schema change is false | ||
sleep(1000) | ||
sql """ alter table ${tbName} ADD COLUMN (new_k1 INT DEFAULT '1', new_k2 INT DEFAULT '2');""" | ||
def waitSchemaChangeJob = { String tableName /* param */ -> | ||
int tryTimes = 30 | ||
while (tryTimes-- > 0) { | ||
def jobResult = sql """SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """ | ||
def jobState = jobResult[0][9].toString() | ||
if ('cancelled'.equalsIgnoreCase(jobState)) { | ||
logger.info("jobResult:{}", jobResult) | ||
throw new IllegalStateException("${tableName}'s job has been cancelled") | ||
} | ||
if ('finished'.equalsIgnoreCase(jobState)) { | ||
logger.info("jobResult:{}", jobResult) | ||
break | ||
} | ||
sleep(10000) | ||
} | ||
} | ||
|
||
waitSchemaChangeJob(tbName) | ||
qt_sql """ DESC ${tbName}""" | ||
|
||
sql """ INSERT INTO ${tbName} VALUES | ||
(7, 7, "zzz", 7, 7, 7, 7, 7), | ||
(8, 8, "zzz", 8, 8, 8, 8, 8), | ||
(9, 9, "zzz", 9, 9, 9, 9, 9); | ||
""" | ||
qt_order """ select * from ${tbName} order by siteid""" | ||
sql "DROP TABLE IF EXISTS ${tbName} FORCE" | ||
} |
Oops, something went wrong.