This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new cc538267a67 [enhancement](regression-test) modify a key type tests
(#34600)
cc538267a67 is described below
commit cc538267a674a17a0a680eb0239ebeef51976352
Author: kkop <[email protected]>
AuthorDate: Fri May 17 13:44:47 2024 +0800
[enhancement](regression-test) modify a key type tests (#34600)
Co-authored-by: cjj2010 <[email protected]>
---
.../test_unique_schema_key_change_modify.groovy | 583 ++++++++++++++++++++-
1 file changed, 580 insertions(+), 3 deletions(-)
diff --git
a/regression-test/suites/schema_change_p0/test_unique_schema_key_change_modify.groovy
b/regression-test/suites/schema_change_p0/test_unique_schema_key_change_modify.groovy
index 3768633f6cf..38185f39d2d 100644
---
a/regression-test/suites/schema_change_p0/test_unique_schema_key_change_modify.groovy
+++
b/regression-test/suites/schema_change_p0/test_unique_schema_key_change_modify.groovy
@@ -24,7 +24,7 @@ suite("test_unique_schema_key_change_modify","p0") {
sql """ DROP TABLE IF EXISTS ${tbName} """
def getTableStatusSql = " SHOW ALTER TABLE COLUMN WHERE
IndexName='${tbName}' ORDER BY createtime DESC LIMIT 1 "
- initTable = " CREATE TABLE IF NOT EXISTS ${tbName}\n" +
+ def initTable = " CREATE TABLE IF NOT EXISTS ${tbName}\n" +
" (\n" +
" `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" +
" `username` VARCHAR(50) NOT NULL COMMENT
\"用户昵称\",\n" +
@@ -43,7 +43,7 @@ suite("test_unique_schema_key_change_modify","p0") {
" \"enable_unique_key_merge_on_write\" = \"true\"\n" +
" );"
- initTableData = "insert into ${tbName} values(123456789, 'Alice', 0,
'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01
10:00:00')," +
+ def initTableData = "insert into ${tbName} values(123456789, 'Alice', 0,
'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01
10:00:00')," +
" (234567890, 'Bob', 0, 'Shanghai', 30, 1,
13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00')," +
" (345678901, 'Carol', 1, 'Guangzhou', 28, 0,
13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00')," +
" (456789012, 'Dave', 0, 'Shenzhen', 35, 1,
13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00')," +
@@ -52,7 +52,7 @@ suite("test_unique_schema_key_change_modify","p0") {
" (789012345, 'Grace', 0, 'Xian', 29, 0,
13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00');"
//TODO Test the unique model by modify a key type from BOOLEAN to TINYINT
- errorMessage="errCode = 2, detailMessage = Can not change BOOLEAN to
TINYINT"
+ def errorMessage="errCode = 2, detailMessage = Can not change BOOLEAN to
TINYINT"
expectException({
sql initTable
sql initTableData
@@ -1136,5 +1136,582 @@ suite("test_unique_schema_key_change_modify","p0") {
}, insertSql, true, "${tbName}")
}, errorMessage)
+ /**
+ * Test the unique model by modify a key type from FLOAT to other type
+ */
+ sql """ DROP TABLE IF EXISTS ${tbName} """
+ initTable = " CREATE TABLE IF NOT EXISTS ${tbName}\n" +
+ " (\n" +
+ " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" +
+ " `username` VARCHAR(50) NOT NULL COMMENT
\"用户昵称\",\n" +
+ " `score` FLOAT COMMENT \"分数\",\n" +
+ " `city` VARCHAR(20) COMMENT \"用户所在城市\",\n" +
+ " `age` SMALLINT COMMENT \"用户年龄\",\n" +
+ " `sex` TINYINT COMMENT \"用户性别\",\n" +
+ " `phone` LARGEINT COMMENT \"用户电话\",\n" +
+ " `address` VARCHAR(500) COMMENT \"用户地址\",\n" +
+ " `register_time` DATETIME COMMENT \"用户注册时间\"\n" +
+ " )\n" +
+ " UNIQUE KEY(`user_id`, `username`,`score`)\n" +
+ " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" +
+ " PROPERTIES (\n" +
+ " \"replication_allocation\" = \"tag.location.default:
1\",\n" +
+ " \"enable_unique_key_merge_on_write\" = \"true\"\n" +
+ " );"
+
+ initTableData = "insert into ${tbName} values(123456789, 'Alice', 1.8,
'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01
10:00:00')," +
+ " (234567890, 'Bob', 1.89, 'Shanghai', 30, 1,
13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00')," +
+ " (345678901, 'Carol', 2.6, 'Guangzhou', 28, 0,
13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00')," +
+ " (456789012, 'Dave', 3.9, 'Shenzhen', 35, 1,
13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00')," +
+ " (567890123, 'Eve', 4.2, 'Chengdu', 27, 0,
13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00')," +
+ " (678901234, 'Frank', 2.5, 'Hangzhou', 32, 1,
13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00')," +
+ " (789012345, 'Grace', 2.1, 'Xian', 29, 0,
13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00');"
+
+ //TODO Test the unique model by modify a key type from FLOAT to BOOLEAN
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score BOOLEAN key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', false,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ // TODO Test the unique model by modify a key type from FLOAT to TINYINT
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score TINYINT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 2,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ //Test the unique model by modify a key type from FLOAT to SMALLINT
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score SMALLINT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 3,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+ //Test the unique model by modify a key type from FLOAT to INT
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+
+ sql """ alter table ${tbName} MODIFY column score INT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 4,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ //Test the unique model by modify a key type from FLOAT to BIGINT
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score BIGINT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice',
545645, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01
10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+ //Test the unique model by modify a key type from FLOAT to LARGEINT
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score FLOAT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice',
156546, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01
10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ //Test the unique model by modify a key type from FLOAT to DOUBLE
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score DOUBLE key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 1.23,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ //TODO Test the unique model by modify a key type from FLOAT to DECIMAL
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score DECIMAL(38,0)
key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 1.23,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+
+ }, errorMessage)
+
+ //TODO Test the unique model by modify a key type from FLOAT to CHAR
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score CHAR(15) key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 'asd',
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+ //TODO Test the unique model by modify a key type from FLOAT to VARCHAR
+ //Test the unique model by modify a key type from FLOAT to VARCHAR
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score VARCHAR(100) key
"""
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 'asd',
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+ //TODO Test the unique model by modify a key type from FLOAT to STRING
+ //Test the unique model by modify a key type from FLOAT to STRING
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score STRING key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 'asd',
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ /**
+ * Test the unique model by modify a key type from DOUBLE to other type
+ */
+ sql """ DROP TABLE IF EXISTS ${tbName} """
+ initTable = " CREATE TABLE IF NOT EXISTS ${tbName}\n" +
+ " (\n" +
+ " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" +
+ " `username` VARCHAR(50) NOT NULL COMMENT
\"用户昵称\",\n" +
+ " `score` DOUBLE COMMENT \"分数\",\n" +
+ " `city` VARCHAR(20) COMMENT \"用户所在城市\",\n" +
+ " `age` SMALLINT COMMENT \"用户年龄\",\n" +
+ " `sex` TINYINT COMMENT \"用户性别\",\n" +
+ " `phone` LARGEINT COMMENT \"用户电话\",\n" +
+ " `address` VARCHAR(500) COMMENT \"用户地址\",\n" +
+ " `register_time` DATETIME COMMENT \"用户注册时间\"\n" +
+ " )\n" +
+ " UNIQUE KEY(`user_id`, `username`,`score`)\n" +
+ " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" +
+ " PROPERTIES (\n" +
+ " \"replication_allocation\" = \"tag.location.default:
1\",\n" +
+ " \"enable_unique_key_merge_on_write\" = \"true\"\n" +
+ " );"
+
+ initTableData = "insert into ${tbName} values(123456789, 'Alice', 1.8,
'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01
10:00:00')," +
+ " (234567890, 'Bob', 1.89, 'Shanghai', 30, 1,
13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00')," +
+ " (345678901, 'Carol', 2.6, 'Guangzhou', 28, 0,
13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00')," +
+ " (456789012, 'Dave', 3.9, 'Shenzhen', 35, 1,
13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00')," +
+ " (567890123, 'Eve', 4.2, 'Chengdu', 27, 0,
13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00')," +
+ " (678901234, 'Frank', 2.5, 'Hangzhou', 32, 1,
13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00')," +
+ " (789012345, 'Grace', 2.1, 'Xian', 29, 0,
13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00');"
+
+ //Test the unique model by modify a key type from DOUBLE to BOOLEAN
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score BOOLEAN key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', false,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ // Test the unique model by modify a key type from DOUBLE to TINYINT
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score TINYINT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 2,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ //Test the unique model by modify a key type from DOUBLE to SMALLINT
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score SMALLINT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 3,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+ //Test the unique model by modify a key type from DOUBLE to INT
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+
+ sql """ alter table ${tbName} MODIFY column score INT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 4,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ //Test the unique model by modify a key type from DOUBLE to BIGINT
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score BIGINT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice',
545645, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01
10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+ //Test the unique model by modify a key type from DOUBLE to LARGEINT
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score FLOAT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice',
156546, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01
10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ //Test the unique model by modify a key type from DOUBLE to FLOAT
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score FLOAT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 1.23,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ // Test the unique model by modify a key type from DOUBLE to DECIMAL
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score DECIMAL(38,0)
key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 1.23,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+
+ }, errorMessage)
+
+ //TODO Test the unique model by modify a key type from DOUBLE to CHAR
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score CHAR(15) key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 'asd',
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+ //TODO Test the unique model by modify a key type from DOUBLE to VARCHAR
+ //Test the unique model by modify a key type from FLOAT to VARCHAR
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score VARCHAR(100) key
"""
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 'asd',
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+ //Test the unique model by modify a key type from DOUBLE to STRING
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column score STRING key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 'asd',
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+ /**
+ * Test the unique model by modify a key type from DECIMAL to other type
+ */
+ sql """ DROP TABLE IF EXISTS ${tbName} """
+ initTable = " CREATE TABLE IF NOT EXISTS ${tbName}\n" +
+ " (\n" +
+ " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" +
+ " `username` VARCHAR(50) NOT NULL COMMENT
\"用户昵称\",\n" +
+ " `rice` DECIMAL(38,10) COMMENT \"米粒\",\n" +
+ " `city` VARCHAR(20) COMMENT \"用户所在城市\",\n" +
+ " `age` SMALLINT COMMENT \"用户年龄\",\n" +
+ " `sex` TINYINT COMMENT \"用户性别\",\n" +
+ " `phone` LARGEINT COMMENT \"用户电话\",\n" +
+ " `address` VARCHAR(500) COMMENT \"用户地址\",\n" +
+ " `register_time` DATETIME COMMENT \"用户注册时间\"\n" +
+ " )\n" +
+ " UNIQUE KEY(`user_id`, `username`,`rice`)\n" +
+ " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" +
+ " PROPERTIES (\n" +
+ " \"replication_allocation\" = \"tag.location.default:
1\",\n" +
+ " \"enable_unique_key_merge_on_write\" = \"true\"\n" +
+ " );"
+
+ initTableData = "insert into ${tbName} values(123456789, 'Alice', 1.8,
'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01
10:00:00')," +
+ " (234567890, 'Bob', 1.89, 'Shanghai', 30, 1,
13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00')," +
+ " (345678901, 'Carol', 2.6, 'Guangzhou', 28, 0,
13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00')," +
+ " (456789012, 'Dave', 3.9, 'Shenzhen', 35, 1,
13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00')," +
+ " (567890123, 'Eve', 4.2, 'Chengdu', 27, 0,
13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00')," +
+ " (678901234, 'Frank', 2.5, 'Hangzhou', 32, 1,
13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00')," +
+ " (789012345, 'Grace', 2.1, 'Xian', 29, 0,
13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00');"
+
+ //Test the unique model by modify a key type from DECIMAL to BOOLEAN
+ errorMessage = "errCode = 2, detailMessage = Can not change DECIMAL128 to
BOOLEAN"
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column rice BOOLEAN key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', false,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ // Test the unique model by modify a key type from DECIMAL to TINYINT
+ errorMessage = "errCode = 2, detailMessage = Can not change DECIMAL128 to
TINYINT"
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column rice TINYINT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 2,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ //Test the unique model by modify a key type from DECIMAL to SMALLINT
+ errorMessage = "errCode = 2, detailMessage = Can not change DECIMAL128 to
SMALLINT"
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column rice SMALLINT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 3,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+ //Test the unique model by modify a key type from DECIMAL to INT
+ errorMessage = "errCode = 2, detailMessage = Can not change DECIMAL128 to
INT"
+ expectException({
+ sql initTable
+ sql initTableData
+
+ sql """ alter table ${tbName} MODIFY column rice INT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 4,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ //Test the unique model by modify a key type from DECIMAL to BIGINT
+ errorMessage = "errCode = 2, detailMessage = Can not change DECIMAL128 to
BIGINT"
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column rice BIGINT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice',
545645, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01
10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+ //Test the unique model by modify a key type from DECIMAL to LARGEINT
+ errorMessage = "errCode = 2, detailMessage = Can not change DECIMAL128 to
LARGEINT"
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column rice LARGEINT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice',
156546, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01
10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ //Test the unique model by modify a key type from DECIMAL to FLOAT
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column rice FLOAT key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 1.23,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+
+ // Test the unique model by modify a key type from DECIMAL to DOUBLE
+ errorMessage = "errCode = 2, detailMessage = Float or double can not used
as a key, use decimal instead."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column rice DOUBLE key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 1.23,
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+
+ }, errorMessage)
+
+ //Test the unique model by modify a key type from DECIMAL to CHAR
+ errorMessage = "errCode = 2, detailMessage = Can not change DECIMAL128 to
CHAR"
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column rice CHAR(15) key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 'asd',
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
+
+ //Test the unique model by modify a key type from DECIMAL to VARCHAR
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column rice VARCHAR(100) key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 'asd',
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, false, "${tbName}")
+
+ sql """ DROP TABLE IF EXISTS ${tbName2} """
+ initTable2 = " CREATE TABLE IF NOT EXISTS ${tbName2}\n" +
+ " (\n" +
+ " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" +
+ " `username` VARCHAR(50) NOT NULL COMMENT
\"用户昵称\",\n" +
+ " `rice` VARCHAR(100) COMMENT \"米粒\",\n" +
+ " `city` VARCHAR(20) COMMENT \"用户所在城市\",\n" +
+ " `age` SMALLINT COMMENT \"用户年龄\",\n" +
+ " `sex` TINYINT COMMENT \"用户性别\",\n" +
+ " `phone` LARGEINT COMMENT \"用户电话\",\n" +
+ " `address` VARCHAR(500) COMMENT \"用户地址\",\n" +
+ " `register_time` DATETIME COMMENT \"用户注册时间\"\n" +
+ " )\n" +
+ " UNIQUE KEY(`user_id`, `username`,`rice`)\n" +
+ " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" +
+ " PROPERTIES (\n" +
+ " \"replication_allocation\" = \"tag.location.default:
1\",\n" +
+ " \"enable_unique_key_merge_on_write\" = \"true\"\n" +
+ " );"
+
+ initTableData2 = "insert into ${tbName2} values(123456789, 'Alice',
'1.8000000000', 'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing',
'2022-01-01 10:00:00')," +
+ " (234567890, 'Bob', '1.8900000000', 'Shanghai',
30, 1, 13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00')," +
+ " (345678901, 'Carol', '2.6000000000', 'Guangzhou',
28, 0, 13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00')," +
+ " (456789012, 'Dave', '3.9000000000', 'Shenzhen',
35, 1, 13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00')," +
+ " (567890123, 'Eve', '4.2000000000', 'Chengdu', 27,
0, 13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00')," +
+ " (678901234, 'Frank', '2.5000000000', 'Hangzhou',
32, 1, 13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00')," +
+ " (123456689, 'Alice', 'asd', 'Yaan', 25, 0,
13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00')," +
+ " (789012345, 'Grace', '2.1000000000', 'Xian', 29,
0, 13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00');"
+
+ sql initTable2
+ sql initTableData2
+ checkTableData("${tbName}","${tbName2}","rice")
+ sql """ DROP TABLE IF EXISTS ${tbName} """
+
+ //Test the unique model by modify a key type from DECIMAL to STRING
+ errorMessage = "errCode = 2, detailMessage = String Type should not be
used in key column[rice]."
+ expectException({
+ sql initTable
+ sql initTableData
+ sql """ alter table ${tbName} MODIFY column rice STRING key """
+ insertSql = "insert into ${tbName} values(123456689, 'Alice', 'asd',
'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
+ waitForSchemaChangeDone({
+ sql getTableStatusSql
+ time 60
+ }, insertSql, true, "${tbName}")
+ }, errorMessage)
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]