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.
[regression](fe) Add more regression test for FE
- Loading branch information
1 parent
a2a157f
commit 442dae4
Showing
8 changed files
with
315 additions
and
0 deletions.
There are no files selected for viewing
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,7 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !sql -- | ||
1 1 xxx 1 | ||
|
||
-- !sql -- | ||
1 1 xxx 1 | ||
|
19 changes: 19 additions & 0 deletions
19
regression-test/data/schema_change/test_alter_table_property_bucket.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,19 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !order -- | ||
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 | ||
|
||
-- !order -- | ||
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 | ||
4 2017-03-01 Beijing 10 1 1 31 21 \N \N | ||
|
||
-- !order -- | ||
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 | ||
4 2017-03-01 Beijing 10 1 1 31 21 \N \N | ||
5 2017-03-01 Beijing 10 1 1 31 21 \N \N | ||
|
9 changes: 9 additions & 0 deletions
9
regression-test/data/schema_change_p0/test_rename_partition.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,9 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !sql -- | ||
1 1 xxx 1 | ||
2 1 yyy 1 | ||
|
||
-- !sql -- | ||
1 1 xxx 1 | ||
2 1 yyy 1 | ||
|
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,7 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !sql -- | ||
1 1 xxx 1 | ||
|
||
-- !sql -- | ||
1 1 xxx 1 | ||
|
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,84 @@ | ||
// 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_db") { | ||
String dbName = "test_alter_db_qwer" | ||
String newDbName = "new_alter_db_qwer" | ||
String tableName = "t1_qwer" | ||
|
||
sql """DROP DATABASE IF EXISTS ${dbName} FORCE;""" | ||
sql """DROP DATABASE IF EXISTS ${newDbName} FORCE;""" | ||
|
||
sql """CREATE DATABASE ${dbName};""" | ||
|
||
sql """ALTER DATABASE ${dbName} SET DATA QUOTA 102400;""" | ||
sql """ALTER DATABASE ${dbName} SET REPLICA QUOTA 1024;""" | ||
sql """ALTER DATABASE ${dbName} SET TRANSACTION QUOTA 1024;""" | ||
|
||
def dbResults = sql """SHOW PROC '/dbs';""" | ||
def found = false | ||
def result = null | ||
for (def dbResult : dbResults) { | ||
logger.debug("dbResult:${dbResult}") | ||
if (dbResult[1].contains(dbName)) { | ||
found = true | ||
result = dbResult | ||
break; | ||
} | ||
} | ||
assertTrue(found) | ||
assertEquals("100.000 KB", result[4]) | ||
assertEquals("1024", result[7]) | ||
assertEquals("1024", result[8]) | ||
|
||
sql """use ${dbName};""" | ||
sql """ | ||
CREATE TABLE `${tableName}` | ||
( | ||
`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 ${dbName}.${tableName}(siteid, citycode, username, pv) VALUES (1, 1, "xxx", 1);""" | ||
sql """SYNC;""" | ||
order_qt_sql """SELECT * FROM ${dbName}.${tableName};""" | ||
|
||
sql """ ALTER DATABASE ${dbName} RENAME ${newDbName};""" | ||
order_qt_sql """SELECT * FROM ${newDbName}.${tableName};""" | ||
|
||
dbResults = sql """SHOW PROC '/dbs';""" | ||
found = false | ||
for (def dbResult : dbResults) { | ||
logger.debug("dbResult:${dbResult}") | ||
if (dbResult[1].contains(dbName)) { | ||
found = true | ||
break; | ||
} | ||
} | ||
assertFalse(found) | ||
|
||
sql """DROP DATABASE IF EXISTS ${dbName} FORCE;""" | ||
sql """DROP DATABASE IF EXISTS ${newDbName} FORCE;""" | ||
} |
77 changes: 77 additions & 0 deletions
77
regression-test/suites/schema_change/test_alter_table_property_bucket.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,77 @@ | ||
// 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_property_bucket") { | ||
def tableName = "test_alter_table_property_bucket" | ||
|
||
sql "DROP TABLE IF EXISTS ${tableName} FORCE" | ||
sql """ | ||
CREATE TABLE ${tableName} ( | ||
`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 ${tableName} 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_order """ select * from ${tableName} order by user_id""" | ||
|
||
// modify in_memory property | ||
// https://github.com/apache/doris/pull/18731 | ||
test { | ||
sql """ALTER TABLE ${tableName} SET ("in_memory" = "true");""" | ||
exception "Not support set 'in_memory'='true' now!" | ||
} | ||
|
||
sql """ INSERT INTO ${tableName} VALUES | ||
(4, '2017-03-01', 'Beijing', 10, 1, 1, 31, 21, hll_hash(2), to_bitmap(2)) | ||
""" | ||
|
||
qt_order """ select * from ${tableName} order by user_id""" | ||
|
||
// modify bucket num | ||
sql """ALTER TABLE ${tableName} MODIFY DISTRIBUTION DISTRIBUTED BY HASH(user_id) BUCKETS 2;""" | ||
|
||
sql """ INSERT INTO ${tableName} VALUES | ||
(5, '2017-03-01', 'Beijing', 10, 1, 1, 31, 21, hll_hash(2), to_bitmap(2)) | ||
""" | ||
qt_order """ select * from ${tableName} order by user_id""" | ||
} |
58 changes: 58 additions & 0 deletions
58
regression-test/suites/schema_change_p0/test_rename_partition.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,58 @@ | ||
// 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_rename_partition") { | ||
String tblName = "test_rename_partition" | ||
sql """DROP TABLE IF EXISTS ${tblName} FORCE; """ | ||
|
||
sql """ | ||
CREATE TABLE `${tblName}` | ||
( | ||
`siteid` INT DEFAULT '10', | ||
`citycode` SMALLINT, | ||
`username` VARCHAR(32) DEFAULT 'test', | ||
`pv` BIGINT SUM DEFAULT '0' | ||
) | ||
AGGREGATE KEY(`siteid`, `citycode`, `username`) | ||
PARTITION BY RANGE(`siteid`) | ||
( | ||
partition `old_p1` values [("1"), ("2")), | ||
partition `old_p2` values [("2"), ("3")) | ||
) | ||
DISTRIBUTED BY HASH(siteid) BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_num" = "1" | ||
); | ||
""" | ||
|
||
sql """INSERT INTO ${tblName}(siteid, citycode, username, pv) VALUES (1, 1, "xxx", 1), (2, 1, "yyy", 1);""" | ||
sql """SYNC;""" | ||
order_qt_sql """SELECT * from ${tblName};""" | ||
|
||
sql """ALTER TABLE ${tblName} RENAME PARTITION old_p1 new_p1;""" | ||
order_qt_sql """SELECT * from ${tblName};""" | ||
|
||
def results = sql """SHOW PARTITIONS FROM ${tblName};""" | ||
for (def result : results) { | ||
logger.info("result:${result}") | ||
if (["new_p1", "old_p2"].contains(result[1])) { | ||
continue; | ||
} | ||
assertTrue(false); | ||
} | ||
sql """DROP TABLE IF EXISTS ${tblName} FORCE; """ | ||
} |
54 changes: 54 additions & 0 deletions
54
regression-test/suites/schema_change_p0/test_rename_table.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,54 @@ | ||
// 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_rename_table") { | ||
String tblName = "test_rename_table" | ||
String newTblName = "new_rename_table" | ||
|
||
sql """DROP TABLE IF EXISTS ${tblName} FORCE; """ | ||
sql """DROP TABLE IF EXISTS ${newTblName} FORCE; """ | ||
|
||
sql """ | ||
CREATE TABLE `${tblName}` | ||
( | ||
`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 ${tblName}(siteid, citycode, username, pv) VALUES (1, 1, "xxx", 1);""" | ||
sql """SYNC;""" | ||
order_qt_sql """SELECT * from ${tblName};""" | ||
|
||
sql """ALTER TABLE ${tblName} RENAME ${newTblName};""" | ||
order_qt_sql """SELECT * from ${newTblName};""" | ||
|
||
String result = sql """SHOW TABLES;""" | ||
|
||
assertFalse(result.contains(tblName)) | ||
assertTrue(result.contains(newTblName)) | ||
|
||
sql """DROP TABLE IF EXISTS ${tblName} FORCE; """ | ||
sql """DROP TABLE IF EXISTS ${newTblName} FORCE; """ | ||
} |