This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new 1accde9fb34 [fix](nestedtype) support nested type for schema change reorder (#39392) 1accde9fb34 is described below commit 1accde9fb34751b5559c4bffde7a78fe7d8250c1 Author: amory <wangqian...@selectdb.com> AuthorDate: Thu Aug 15 14:03:03 2024 +0800 [fix](nestedtype) support nested type for schema change reorder (#39392) ## Proposed changes backport: https://github.com/apache/doris/pull/39210 Issue Number: close #xxx <!--Describe your changes.--> --- .../main/java/org/apache/doris/catalog/Column.java | 5 + .../java/org/apache/doris/catalog/ColumnType.java | 6 +- .../ddl/create_nestedtypes_with_schemachange.out | 46 + .../create_nestedtypes_with_schemachange.groovy | 65 ++ .../test_dup_schema_value_modify3.groovy | 1091 ++++++++++++++++++++ .../test_dup_schema_value_modify4.groovy | 1089 +++++++++++++++++++ .../test_unique_schema_value_modify3.groovy | 60 +- 7 files changed, 2329 insertions(+), 33 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java index 6aefc66eacd..b600f31ca20 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java @@ -648,6 +648,11 @@ public class Column implements Writable, GsonPostProcessable { throw new DdlException("Dest column name is empty"); } + // now nested type can only support change order + if (type.isComplexType() && !type.equals(other.type)) { + throw new DdlException("Can not change " + type + " to " + other); + } + if (!ColumnType.isSchemaChangeAllowed(type, other.type)) { throw new DdlException("Can not change " + getDataType() + " to " + other.getDataType()); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnType.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnType.java index 954e2e2c901..69199a81a53 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnType.java @@ -156,9 +156,9 @@ public abstract class ColumnType { schemaChangeMatrix[PrimitiveType.DATETIMEV2.ordinal()][PrimitiveType.DATETIMEV2.ordinal()] = true; // Currently, we do not support schema change between complex types with subtypes. - schemaChangeMatrix[PrimitiveType.ARRAY.ordinal()][PrimitiveType.ARRAY.ordinal()] = false; - schemaChangeMatrix[PrimitiveType.STRUCT.ordinal()][PrimitiveType.STRUCT.ordinal()] = false; - schemaChangeMatrix[PrimitiveType.MAP.ordinal()][PrimitiveType.MAP.ordinal()] = false; + schemaChangeMatrix[PrimitiveType.ARRAY.ordinal()][PrimitiveType.ARRAY.ordinal()] = true; + schemaChangeMatrix[PrimitiveType.STRUCT.ordinal()][PrimitiveType.STRUCT.ordinal()] = true; + schemaChangeMatrix[PrimitiveType.MAP.ordinal()][PrimitiveType.MAP.ordinal()] = true; } static boolean isSchemaChangeAllowed(Type lhs, Type rhs) { diff --git a/regression-test/data/datatype_p0/nested_types/ddl/create_nestedtypes_with_schemachange.out b/regression-test/data/datatype_p0/nested_types/ddl/create_nestedtypes_with_schemachange.out new file mode 100644 index 00000000000..af88eb6b9bb --- /dev/null +++ b/regression-test/data/datatype_p0/nested_types/ddl/create_nestedtypes_with_schemachange.out @@ -0,0 +1,46 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !sql -- +col0 bigint No true \N +col_array array<text> Yes false \N NONE +col2 int No false \N NONE +col3 array<int> Yes false \N NONE +col4 map<int,int> Yes false \N NONE +col5 struct<f1:int> Yes false \N NONE + +-- !sql -- +col0 bigint No true \N +col_map map<char(32),text> Yes false \N NONE +col2 int No false \N NONE +col3 array<int> Yes false \N NONE +col4 map<int,int> Yes false \N NONE +col5 struct<f1:int> Yes false \N NONE + +-- !sql -- +col0 bigint No true \N +col_struct struct<f1:varchar(1)> Yes false \N NONE +col2 int No false \N NONE +col3 array<int> Yes false \N NONE +col4 map<int,int> Yes false \N NONE +col5 struct<f1:int> Yes false \N NONE + +-- !sql -- +col0 bigint No true \N +col2 int No false \N NONE +col3 array<int> Yes false \N NONE +col4 map<int,int> Yes false \N NONE +col5 struct<f1:int> Yes false \N NONE + +-- !sql -- +col0 bigint No true \N +col2 int No false \N NONE +col3 array<int> Yes false \N NONE +col4 map<int,int> Yes false \N NONE +col5 struct<f1:int> Yes false \N NONE + +-- !sql -- +col0 bigint No true \N +col2 int No false \N NONE +col3 array<int> Yes false \N NONE +col4 map<int,int> Yes false \N NONE +col5 struct<f1:int> Yes false \N NONE + diff --git a/regression-test/suites/datatype_p0/nested_types/ddl/create_nestedtypes_with_schemachange.groovy b/regression-test/suites/datatype_p0/nested_types/ddl/create_nestedtypes_with_schemachange.groovy new file mode 100644 index 00000000000..ec0f163821d --- /dev/null +++ b/regression-test/suites/datatype_p0/nested_types/ddl/create_nestedtypes_with_schemachange.groovy @@ -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("create_nestedtypes_with_schemachange", "p0") { + + def create_nested_table_and_schema_change = {testTablex, nested_type, column_name, error -> + // create basic type + sql "DROP TABLE IF EXISTS $testTablex" + sql """ CREATE TABLE $testTablex ( + col0 BIGINT NOT NULL, col2 int NOT NULL, col3 array<int> NULL, col4 map<int, int> NULL, col5 struct<f1: int> NULL + ) + /* mow */ + UNIQUE KEY(col0) DISTRIBUTED BY HASH(col0) BUCKETS 4 PROPERTIES ( + "enable_unique_key_merge_on_write" = "true", + "replication_num" = "1" + ); """ + // alter table add nested type + if (error != '') { + // check nested type do not support other type + test { + sql "ALTER TABLE $testTablex MODIFY COLUMN $column_name $nested_type AFTER col0" + exception (error) + } + } else { + // check nested type can only support change order + sql "ALTER TABLE $testTablex ADD COLUMN $column_name $nested_type" + sql "ALTER TABLE $testTablex MODIFY COLUMN $column_name $nested_type AFTER col0" + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='$testTablex' ORDER BY createtime DESC LIMIT 1 """ + time 600 + } + } + // desc table + qt_sql "DESC $testTablex" + } + + // array + create_nested_table_and_schema_change.call("test_array_schemachange", "ARRAY<STRING>", "col_array", '') + // map + create_nested_table_and_schema_change.call("test_map_schemachange", "MAP<char(32), string>", "col_map", '') + // struct + create_nested_table_and_schema_change.call("test_struct_schemachange", "STRUCT<f1: varchar(1)>", "col_struct", '') + + // array with other type + create_nested_table_and_schema_change.call("test_array_schemachange_1", "ARRAY<STRING>", "col3", "errCode = 2"); + // map with other type + create_nested_table_and_schema_change.call("test_map_schemachange_1", "MAP<char(32), string>", "col4", "errCode = 2"); + // struct with other type + create_nested_table_and_schema_change.call("test_struct_schemachange_1", "STRUCT<f1: varchar(1)>", "col5", "errCode = 2"); + +} diff --git a/regression-test/suites/schema_change_p0/test_dup_schema_value_modify3.groovy b/regression-test/suites/schema_change_p0/test_dup_schema_value_modify3.groovy new file mode 100644 index 00000000000..caa7a3ffa79 --- /dev/null +++ b/regression-test/suites/schema_change_p0/test_dup_schema_value_modify3.groovy @@ -0,0 +1,1091 @@ +// 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_dup_schema_value_modify3", "p0") { + def tbName1 = "dup_model_value_change3" + def tbName2 = "dup_model_value_change_3" + //Test the dup model by adding a value column + sql """ DROP TABLE IF EXISTS ${tbName1} """ + def getTableStatusSql = " SHOW ALTER TABLE COLUMN WHERE IndexName='${tbName1}' ORDER BY createtime DESC LIMIT 1 " + def errorMessage = "" + /** + * Test the dup model by modify a value type + */ + def initTable2 = "" + def initTableData2 = "" + sql """ DROP TABLE IF EXISTS ${tbName1} """ + def initTable = " CREATE TABLE IF NOT EXISTS ${tbName1}\n" + + " (\n" + + " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" + + " `username` VARCHAR(50) NOT NULL COMMENT \"用户昵称\",\n" + + " `is_teacher` BOOLEAN 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" + + " DUPLICATE KEY(`user_id`, `username`)\n" + + " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" + + " PROPERTIES (\n" + + " \"replication_allocation\" = \"tag.location.default: 1\"\n" + + " );" + + def initTableData = "insert into ${tbName1} 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')," + + " (567890123, 'Eve', 0, 'Chengdu', 27, 0, 13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00')," + + " (678901234, 'Frank', 1, 'Hangzhou', 32, 1, 13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00')," + + " (789012345, 'Grace', 0, 'Xian', 29, 0, 13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00');" + + + /** + * Test the dup model by modify a value type from MAP to other type + */ + sql """ DROP TABLE IF EXISTS ${tbName1} """ + initTable = " CREATE TABLE IF NOT EXISTS ${tbName1}\n" + + " (\n" + + " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" + + " `username` VARCHAR(50) NOT NULL COMMENT \"用户昵称\",\n" + + " `score` DECIMAL(38,10) COMMENT \"分数\",\n" + + " `city` CHAR(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" + + " `m` Map<STRING, INT> NULL COMMENT \"\",\n" + + " `j` JSON NULL COMMENT \"\"\n" + + " )\n" + + " DUPLICATE KEY(`user_id`, `username`)\n" + + " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" + + " PROPERTIES (\n" + + " \"replication_allocation\" = \"tag.location.default: 1\"\n" + + " );" + + initTableData = "insert into ${tbName1} values(123456789, 'Alice', 1.83, 'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 100, 'b': 200}, '[\"abc\", \"def\"]')," + + " (234567890, 'Bob', 1.89, 'Shanghai', 30, 1, 13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00', {'a': 200, 'b': 200}, '[\"abc\", \"def\"]')," + + " (345678901, 'Carol', 2.6689, 'Guangzhou', 28, 0, 13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00', {'a': 300, 'b': 200}, '[\"abc\", \"def\"]')," + + " (456789012, 'Dave', 3.9456, 'Shenzhen', 35, 1, 13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00', {'a': 400, 'b': 200}, '[\"abc\", \"def\"]')," + + " (567890123, 'Eve', 4.223, 'Chengdu', 27, 0, 13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00', {'a': 500, 'b': 200}, '[\"abc\", \"def\"]')," + + " (678901234, 'Frank', 2.5454, 'Hangzhou', 32, 1, 13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00', {'a': 600, 'b': 200}, '[\"abc\", \"def\"]')," + + " (789012345, 'Grace', 2.19656, 'Xian', 29, 0, 13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]');" + + //TODO Test the dup model by modify a value type from MAP to BOOLEAN + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m BOOLEAN """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', false, '{\"k1\":\"v1\", \"k2\": 200}'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + // TODO Test the dup model by modify a value type from MAP to TINYINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m TINYINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 1, '{\"k1\":\"v1\", \"k2\": 200}'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 120 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from MAP to SMALLINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m SMALLINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 3, [\"abc\", \"def\"]); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from MAP to INT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m INT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 4.1, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 23, [\"abc\", \"def\"]); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from MAP to BIGINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m BIGINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 4564, [\"abc\", \"def\"]); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from MAP to LARGEINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m LARGEINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.36, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 43643734, [\"abc\", \"def\"]); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from MAP to FLOAT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m FLOAT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 5.6, '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //TODO Test the dup model by modify a value type from MAP to DECIMAL + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m DECIMAL(38,0) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 895.666, '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from MAP to DATE + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m DATE """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', '2003-12-31', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from MAP to DATEV2 + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m DATEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', '2003-12-31', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from MAP to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m DATETIME """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 9.63, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', '2003-12-31 20:12:12', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from MAP to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m DATETIMEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', '2003-12-31 20:12:12', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from MAP to VARCHAR + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m VARCHAR(100) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 'sdfghjk', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from MAP to STRING + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m STRING """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.59, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 'wertyu', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from MAP to JSON + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m JSON """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', '{'a': 100, 'b': 200}', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + /** + * Test the dup model by modify a value type from JSON to other type + */ + sql """ DROP TABLE IF EXISTS ${tbName1} """ + initTable = " CREATE TABLE IF NOT EXISTS ${tbName1}\n" + + " (\n" + + " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" + + " `username` VARCHAR(50) NOT NULL COMMENT \"用户昵称\",\n" + + " `score` DECIMAL(38,10) COMMENT \"分数\",\n" + + " `city` CHAR(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" + + " `m` Map<STRING, INT> NULL COMMENT \"\",\n" + + " `j` JSON NULL COMMENT \"\"\n" + + " )\n" + + " DUPLICATE KEY(`user_id`, `username`)\n" + + " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" + + " PROPERTIES (\n" + + " \"replication_allocation\" = \"tag.location.default: 1\"\n" + + " );" + + initTableData = "insert into ${tbName1} values(123456789, 'Alice', 1.83, 'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 100, 'b': 200}, '[\"abc\", \"def\"]')," + + " (234567890, 'Bob', 1.89, 'Shanghai', 30, 1, 13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00', {'a': 200, 'b': 200}, '[\"abc\", \"def\"]')," + + " (345678901, 'Carol', 2.6689, 'Guangzhou', 28, 0, 13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00', {'a': 300, 'b': 200}, '[\"abc\", \"def\"]')," + + " (456789012, 'Dave', 3.9456, 'Shenzhen', 35, 1, 13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00', {'a': 400, 'b': 200}, '[\"abc\", \"def\"]')," + + " (567890123, 'Eve', 4.223, 'Chengdu', 27, 0, 13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00', {'a': 500, 'b': 200}, '[\"abc\", \"def\"]')," + + " (678901234, 'Frank', 2.5454, 'Hangzhou', 32, 1, 13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00', {'a': 600, 'b': 200}, '[\"abc\", \"def\"]')," + + " (789012345, 'Grace', 2.19656, 'Xian', 29, 0, 13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]');" + + //TODO Test the dup model by modify a value type from JSON to BOOLEAN + errorMessage = "errCode = 2, detailMessage = Can not change JSON to BOOLEAN" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j BOOLEAN """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', , false); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + // TODO Test the dup model by modify a value type from JSON to TINYINT + errorMessage = "errCode = 2, detailMessage = Can not change JSON to TINYINT" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j TINYINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 1); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 120 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from JSON to SMALLINT + errorMessage = "errCode = 2, detailMessage = Can not change JSON to SMALLINT" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j SMALLINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 21); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from JSON to INT + errorMessage = "errCode = 2, detailMessage = Can not change JSON to INT" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j INT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 4.1, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 25); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from JSON to BIGINT + errorMessage = "errCode = 2, detailMessage = Can not change JSON to BIGINT" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j BIGINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 32523); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from JSON to LARGEINT + errorMessage = "errCode = 2, detailMessage = Can not change JSON to LARGEINT" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j LARGEINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.36, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 356436); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from JSON to FLOAT + errorMessage = "errCode = 2, detailMessage = Can not change JSON to FLOAT" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j FLOAT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 86.5); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //TODO Test the dup model by modify a value type from JSON to DECIMAL + errorMessage = "errCode = 2, detailMessage = Can not change JSON to DECIMAL128" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j DECIMAL(38,0) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 896.2356); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from JSON to DATE + errorMessage = "errCode = 2, detailMessage = Can not change JSON to DATEV2" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j DATE """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '2003-12-31'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from JSON to DATEV2 + errorMessage = "errCode = 2, detailMessage = Can not change JSON to DATEV2" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j DATEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '2003-12-31'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from JSON to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change JSON to DATETIMEV2" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j DATETIME """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 9.63, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '2003-12-31 20:12:12'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from JSON to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change JSON to DATETIMEV2" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j DATETIMEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '2003-12-31 20:12:12'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from JSON to VARCHAR + errorMessage = "errCode = 2, detailMessage = Can not change JSON to VARCHAR" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j VARCHAR(100) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 'erwtewxa'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from JSON to STRING + errorMessage = "errCode = 2, detailMessage = Can not change JSON to STRING" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j STRING """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.59, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '36tgeryda'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from JSON to MAP + errorMessage = "errCode = 2" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j Map<STRING, INT> """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, {'a': 700, 'b': 200}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + /** + * Test the dup model by modify a value type from array to other type + */ + sql """ DROP TABLE IF EXISTS ${tbName1} """ + initTable = " CREATE TABLE IF NOT EXISTS ${tbName1}\n" + + " (\n" + + " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" + + " `username` VARCHAR(50) NOT NULL COMMENT \"用户昵称\",\n" + + " `score` DECIMAL(38,10) COMMENT \"分数\",\n" + + " `city` CHAR(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" + + " `m` Map<STRING, INT> NULL COMMENT \"\",\n" + + " `j` JSON NULL COMMENT \"\",\n" + + " `array` ARRAY<int(11)> NULL COMMENT \"\",\n" + + " `STRUCT` STRUCT<s_id:int(11), s_name:string, s_address:string> NULL COMMENT \"\"\n" + + " )\n" + + " DUPLICATE KEY(`user_id`, `username`)\n" + + " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" + + " PROPERTIES (\n" + + " \"replication_allocation\" = \"tag.location.default: 1\"\n" + + " );" + + initTableData = "insert into ${tbName1} values(123456789, 'Alice', 1.83, 'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 100, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (234567890, 'Bob', 1.89, 'Shanghai', 30, 1, 13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00', {'a': 200, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (345678901, 'Carol', 2.6689, 'Guangzhou', 28, 0, 13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00', {'a': 300, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (456789012, 'Dave', 3.9456, 'Shenzhen', 35, 1, 13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00', {'a': 400, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (567890123, 'Eve', 4.223, 'Chengdu', 27, 0, 13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00', {'a': 500, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (678901234, 'Frank', 2.5454, 'Hangzhou', 32, 1, 13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00', {'a': 600, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (789012345, 'Grace', 2.19656, 'Xian', 29, 0, 13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'});" + + //TODO Test the dup model by modify a value type from array to BOOLEAN + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array BOOLEAN """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', false, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + // TODO Test the dup model by modify a value type from ARRAY to TINYINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array TINYINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 1, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 120 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from ARRAY to SMALLINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array SMALLINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 21, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from ARRAY to INT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array INT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 4.1, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 25, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from ARRAY to BIGINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array BIGINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 32454, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from ARRAY to LARGEINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array LARGEINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.36, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 34235, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from ARRAY to FLOAT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array FLOAT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 45,8, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //TODO Test the dup model by modify a value type from ARRAY to DECIMAL + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array DECIMAL(38,0) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 677.908, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from ARRAY to DATE + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array DATE """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', '2023-10-23', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from ARRAY to DATEV2 + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array DATEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', '2023-10-23', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from ARRAY to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array DATETIME """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 9.63, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', '2023-10-23 15:00:26', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from ARRAY to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array DATETIMEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', '2023-10-26 15:54:21', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from ARRAY to VARCHAR + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array VARCHAR(100) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 'wrwertew', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from ARRAY to STRING + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array STRING """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.59, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 'eterytergfds', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from ARRAY to JSON + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array JSON """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', {'a': 700, 'b':500}, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from ARRAY to JSON + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array Map<STRING, INT> """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', '[\"abc\", \"def\"]', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from ARRAY to JSON + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array STRUCT<s_id:int(11), s_name:string, s_address:string> """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', '[\"abc\", \"def\"]', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + /** + * Test the dup model by modify a value type from STRUCT to other type + */ + sql """ DROP TABLE IF EXISTS ${tbName1} """ + initTable = " CREATE TABLE IF NOT EXISTS ${tbName1}\n" + + " (\n" + + " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" + + " `username` VARCHAR(50) NOT NULL COMMENT \"用户昵称\",\n" + + " `score` DECIMAL(38,10) COMMENT \"分数\",\n" + + " `city` CHAR(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" + + " `m` Map<STRING, INT> NULL COMMENT \"\",\n" + + " `j` JSON NULL COMMENT \"\",\n" + + " `array` ARRAY<int(11)> NULL COMMENT \"\",\n" + + " `STRUCT` STRUCT<s_id:int(11), s_name:string, s_address:string> NULL COMMENT \"\"\n" + + " )\n" + + " DUPLICATE KEY(`user_id`, `username`)\n" + + " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" + + " PROPERTIES (\n" + + " \"replication_allocation\" = \"tag.location.default: 1\"\n" + + " );" + + initTableData = "insert into ${tbName1} values(123456789, 'Alice', 1.83, 'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 100, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (234567890, 'Bob', 1.89, 'Shanghai', 30, 1, 13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00', {'a': 200, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (345678901, 'Carol', 2.6689, 'Guangzhou', 28, 0, 13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00', {'a': 300, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (456789012, 'Dave', 3.9456, 'Shenzhen', 35, 1, 13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00', {'a': 400, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (567890123, 'Eve', 4.223, 'Chengdu', 27, 0, 13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00', {'a': 500, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (678901234, 'Frank', 2.5454, 'Hangzhou', 32, 1, 13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00', {'a': 600, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (789012345, 'Grace', 2.19656, 'Xian', 29, 0, 13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'});" + + //TODO Test the dup model by modify a value type from STRUCT to BOOLEAN + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT BOOLEAN """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], false); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + // TODO Test the dup model by modify a value type from STRUCT to TINYINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT TINYINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 1); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 120 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from STRUCT to SMALLINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT SMALLINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 21); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from STRUCT to INT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT INT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 4.1, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 21); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from STRUCT to BIGINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT BIGINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 32454); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from STRUCT to LARGEINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT LARGEINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.36, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 34235); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from STRUCT to FLOAT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT FLOAT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 45.5); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //TODO Test the dup model by modify a value type from STRUCT to DECIMAL + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT DECIMAL(38,0) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 677.908); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from STRUCT to DATE + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT DATE """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], '2023-10-23'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from STRUCT to DATEV2 + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT DATEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], '2023-10-23'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from STRUCT to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT DATETIME """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 9.63, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], '2023-10-23 15:00:26'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from STRUCT to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT DATETIMEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], '2023-10-26 15:54:21'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from STRUCT to VARCHAR + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT VARCHAR(100) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], "ertet"); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from STRUCT to STRING + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT STRING """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.59, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], "wrwerew"); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from STRUCT to JSON + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT JSON """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], {'a': 700, 'b': 200}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from STRUCT to MAP + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT Map<STRING, INT> """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from STRUCT to ARRAY + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT ARRAY<int(11)> """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + +} diff --git a/regression-test/suites/schema_change_p0/test_dup_schema_value_modify4.groovy b/regression-test/suites/schema_change_p0/test_dup_schema_value_modify4.groovy new file mode 100644 index 00000000000..525fc691688 --- /dev/null +++ b/regression-test/suites/schema_change_p0/test_dup_schema_value_modify4.groovy @@ -0,0 +1,1089 @@ +// 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_dup_schema_value_modify4", "p0") { + def tbName1 = "test_dup_model_value_change3" + def tbName2 = "test_dup_model_value_change_3" + + //Test the dup model by adding a value column + sql """ DROP TABLE IF EXISTS ${tbName1} """ + def initTable = " CREATE TABLE IF NOT EXISTS ${tbName1}\n" + + " (\n" + + " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" + + " `username` VARCHAR(50) NOT NULL 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" + + " DUPLICATE KEY(`user_id`, `username`)\n" + + " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" + + " PROPERTIES (\n" + + " \"replication_allocation\" = \"tag.location.default: 1\"\n" + + " );" + + def initTableData = "insert into ${tbName1} values(123456789, 'Alice', 'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00')," + + " (234567890, 'Bob', 'Shanghai', 30, 1, 13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00')," + + " (345678901, 'Carol', 'Guangzhou', 28, 0, 13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00')," + + " (456789012, 'Dave', 'Shenzhen', 35, 1, 13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00')," + + " (567890123, 'Eve', 'Chengdu', 27, 0, 13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00')," + + " (678901234, 'Frank', 'Hangzhou', 32, 1, 13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00')," + + " (789012345, 'Grace', 'Xian', 29, 0, 13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00');" + + //Test the dup model by adding a value column with VARCHAR + sql initTable + sql initTableData + def getTableStatusSql = " SHOW ALTER TABLE COLUMN WHERE IndexName='${tbName1}' ORDER BY createtime DESC LIMIT 1 " + def errorMessage = "" + def insertSql = "insert into ${tbName1} values(923456689, 'Alice', '四川省', 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00');" + + + /** + * Test the dup model by modify a value type from MAP to other type + */ + sql """ DROP TABLE IF EXISTS ${tbName1} """ + initTable = " CREATE TABLE IF NOT EXISTS ${tbName1}\n" + + " (\n" + + " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" + + " `username` VARCHAR(50) NOT NULL COMMENT \"用户昵称\",\n" + + " `score` DECIMAL(38,10) COMMENT \"分数\",\n" + + " `city` CHAR(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" + + " `m` Map<STRING, INT> NULL COMMENT \"\",\n" + + " `j` JSON NULL COMMENT \"\"\n" + + " )\n" + + " DUPLICATE KEY(`user_id`, `username`)\n" + + " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" + + " PROPERTIES (\n" + + " \"replication_allocation\" = \"tag.location.default: 1\"\n" + + " );" + + initTableData = "insert into ${tbName1} values(123456789, 'Alice', 1.83, 'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 100, 'b': 200}, '[\"abc\", \"def\"]')," + + " (234567890, 'Bob', 1.89, 'Shanghai', 30, 1, 13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00', {'a': 200, 'b': 200}, '[\"abc\", \"def\"]')," + + " (345678901, 'Carol', 2.6689, 'Guangzhou', 28, 0, 13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00', {'a': 300, 'b': 200}, '[\"abc\", \"def\"]')," + + " (456789012, 'Dave', 3.9456, 'Shenzhen', 35, 1, 13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00', {'a': 400, 'b': 200}, '[\"abc\", \"def\"]')," + + " (567890123, 'Eve', 4.223, 'Chengdu', 27, 0, 13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00', {'a': 500, 'b': 200}, '[\"abc\", \"def\"]')," + + " (678901234, 'Frank', 2.5454, 'Hangzhou', 32, 1, 13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00', {'a': 600, 'b': 200}, '[\"abc\", \"def\"]')," + + " (789012345, 'Grace', 2.19656, 'Xian', 29, 0, 13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]');" + + //TODO Test the dup model by modify a value type from MAP to BOOLEAN + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m BOOLEAN """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', false, '{\"k1\":\"v1\", \"k2\": 200}'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + // TODO Test the dup model by modify a value type from MAP to TINYINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m TINYINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 1, '{\"k1\":\"v1\", \"k2\": 200}'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from MAP to SMALLINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m SMALLINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 3, [\"abc\", \"def\"]); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from MAP to INT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m INT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 4.1, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 23, [\"abc\", \"def\"]); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from MAP to BIGINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m BIGINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 4564, [\"abc\", \"def\"]); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from MAP to LARGEINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m LARGEINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.36, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 43643734, [\"abc\", \"def\"]); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from MAP to FLOAT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m FLOAT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 5.6, '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //TODO Test the dup model by modify a value type from MAP to DECIMAL + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m DECIMAL(38,0) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 895.666, '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from MAP to DATE + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m DATE """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', '2003-12-31', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from MAP to DATEV2 + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m DATEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', '2003-12-31', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from MAP to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m DATETIME """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 9.63, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', '2003-12-31 20:12:12', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from MAP to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m DATETIMEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', '2003-12-31 20:12:12', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from MAP to VARCHAR + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m VARCHAR(100) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 'sdfghjk', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from MAP to STRING + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m STRING """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.59, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', 'wertyu', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from MAP to JSON + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column m JSON """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', '{'a': 100, 'b': 200}', '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + /** + * Test the dup model by modify a value type from JSON to other type + */ + sql """ DROP TABLE IF EXISTS ${tbName1} """ + initTable = " CREATE TABLE IF NOT EXISTS ${tbName1}\n" + + " (\n" + + " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" + + " `username` VARCHAR(50) NOT NULL COMMENT \"用户昵称\",\n" + + " `score` DECIMAL(38,10) COMMENT \"分数\",\n" + + " `city` CHAR(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" + + " `m` Map<STRING, INT> NULL COMMENT \"\",\n" + + " `j` JSON NULL COMMENT \"\"\n" + + " )\n" + + " DUPLICATE KEY(`user_id`, `username`)\n" + + " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" + + " PROPERTIES (\n" + + " \"replication_allocation\" = \"tag.location.default: 1\"\n" + + " );" + + initTableData = "insert into ${tbName1} values(123456789, 'Alice', 1.83, 'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 100, 'b': 200}, '[\"abc\", \"def\"]')," + + " (234567890, 'Bob', 1.89, 'Shanghai', 30, 1, 13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00', {'a': 200, 'b': 200}, '[\"abc\", \"def\"]')," + + " (345678901, 'Carol', 2.6689, 'Guangzhou', 28, 0, 13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00', {'a': 300, 'b': 200}, '[\"abc\", \"def\"]')," + + " (456789012, 'Dave', 3.9456, 'Shenzhen', 35, 1, 13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00', {'a': 400, 'b': 200}, '[\"abc\", \"def\"]')," + + " (567890123, 'Eve', 4.223, 'Chengdu', 27, 0, 13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00', {'a': 500, 'b': 200}, '[\"abc\", \"def\"]')," + + " (678901234, 'Frank', 2.5454, 'Hangzhou', 32, 1, 13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00', {'a': 600, 'b': 200}, '[\"abc\", \"def\"]')," + + " (789012345, 'Grace', 2.19656, 'Xian', 29, 0, 13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]');" + + //TODO Test the dup model by modify a value type from JSON to BOOLEAN + errorMessage = "errCode = 2, detailMessage = Can not change JSON to BOOLEAN" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j BOOLEAN """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', , false); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + // TODO Test the dup model by modify a value type from JSON to TINYINT + errorMessage = "errCode = 2, detailMessage = Can not change JSON to TINYINT" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j TINYINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 1); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from JSON to SMALLINT + errorMessage = "errCode = 2, detailMessage = Can not change JSON to SMALLINT" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j SMALLINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 21); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from JSON to INT + errorMessage = "errCode = 2, detailMessage = Can not change JSON to INT" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j INT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 4.1, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 25); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from JSON to BIGINT + errorMessage = "errCode = 2, detailMessage = Can not change JSON to BIGINT" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j BIGINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 32523); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from JSON to LARGEINT + errorMessage = "errCode = 2, detailMessage = Can not change JSON to LARGEINT" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j LARGEINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.36, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 356436); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from JSON to FLOAT + errorMessage = "errCode = 2, detailMessage = Can not change JSON to FLOAT" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j FLOAT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 86.5); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //TODO Test the dup model by modify a value type from JSON to DECIMAL + errorMessage = "errCode = 2, detailMessage = Can not change JSON to DECIMAL128" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j DECIMAL(38,0) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 896.2356); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from JSON to DATE + errorMessage = "errCode = 2, detailMessage = Can not change JSON to DATEV2" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j DATE """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '2003-12-31'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from JSON to DATEV2 + errorMessage = "errCode = 2, detailMessage = Can not change JSON to DATEV2" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j DATEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '2003-12-31'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from JSON to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change JSON to DATETIMEV2" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j DATETIME """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 9.63, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '2003-12-31 20:12:12'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from JSON to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change JSON to DATETIMEV2" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j DATETIMEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '2003-12-31 20:12:12'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from JSON to VARCHAR + errorMessage = "errCode = 2, detailMessage = Can not change JSON to VARCHAR" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j VARCHAR(100) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, 'erwtewxa'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from JSON to STRING + errorMessage = "errCode = 2, detailMessage = Can not change JSON to STRING" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j STRING """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.59, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '36tgeryda'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from JSON to MAP + errorMessage = "errCode = 2" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column j Map<STRING, INT> """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, {'a': 700, 'b': 200}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + /** + * Test the dup model by modify a value type from array to other type + */ + sql """ DROP TABLE IF EXISTS ${tbName1} """ + initTable = " CREATE TABLE IF NOT EXISTS ${tbName1}\n" + + " (\n" + + " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" + + " `username` VARCHAR(50) NOT NULL COMMENT \"用户昵称\",\n" + + " `score` DECIMAL(38,10) COMMENT \"分数\",\n" + + " `city` CHAR(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" + + " `m` Map<STRING, INT> NULL COMMENT \"\",\n" + + " `j` JSON NULL COMMENT \"\",\n" + + " `array` ARRAY<int(11)> NULL COMMENT \"\",\n" + + " `STRUCT` STRUCT<s_id:int(11), s_name:string, s_address:string> NULL COMMENT \"\"\n" + + " )\n" + + " DUPLICATE KEY(`user_id`, `username`)\n" + + " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" + + " PROPERTIES (\n" + + " \"replication_allocation\" = \"tag.location.default: 1\"\n" + + " );" + + initTableData = "insert into ${tbName1} values(123456789, 'Alice', 1.83, 'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 100, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (234567890, 'Bob', 1.89, 'Shanghai', 30, 1, 13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00', {'a': 200, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (345678901, 'Carol', 2.6689, 'Guangzhou', 28, 0, 13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00', {'a': 300, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (456789012, 'Dave', 3.9456, 'Shenzhen', 35, 1, 13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00', {'a': 400, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (567890123, 'Eve', 4.223, 'Chengdu', 27, 0, 13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00', {'a': 500, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (678901234, 'Frank', 2.5454, 'Hangzhou', 32, 1, 13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00', {'a': 600, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (789012345, 'Grace', 2.19656, 'Xian', 29, 0, 13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'});" + + //TODO Test the dup model by modify a value type from array to BOOLEAN + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array BOOLEAN """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', false, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + // TODO Test the dup model by modify a value type from ARRAY to TINYINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array TINYINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 1, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from ARRAY to SMALLINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array SMALLINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 21, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from ARRAY to INT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array INT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 4.1, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 25, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from ARRAY to BIGINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array BIGINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 32454, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from ARRAY to LARGEINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array LARGEINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.36, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 34235, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from ARRAY to FLOAT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array FLOAT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 45,8, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //TODO Test the dup model by modify a value type from ARRAY to DECIMAL + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array DECIMAL(38,0) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 677.908, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from ARRAY to DATE + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array DATE """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', '2023-10-23', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from ARRAY to DATEV2 + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array DATEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', '2023-10-23', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from ARRAY to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array DATETIME """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 9.63, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', '2023-10-23 15:00:26', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from ARRAY to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array DATETIMEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', '2023-10-26 15:54:21', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from ARRAY to VARCHAR + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array VARCHAR(100) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 'wrwertew', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from ARRAY to STRING + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array STRING """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.59, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', 'eterytergfds', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from ARRAY to JSON + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array JSON """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', {'a': 700, 'b':500}, {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from ARRAY to JSON + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array Map<STRING, INT> """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', '[\"abc\", \"def\"]', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from ARRAY to JSON + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column array STRUCT<s_id:int(11), s_name:string, s_address:string> """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', '[\"abc\", \"def\"]', {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + /** + * Test the dup model by modify a value type from STRUCT to other type + */ + sql """ DROP TABLE IF EXISTS ${tbName1} """ + initTable = " CREATE TABLE IF NOT EXISTS ${tbName1}\n" + + " (\n" + + " `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" + + " `username` VARCHAR(50) NOT NULL COMMENT \"用户昵称\",\n" + + " `score` DECIMAL(38,10) COMMENT \"分数\",\n" + + " `city` CHAR(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" + + " `m` Map<STRING, INT> NULL COMMENT \"\",\n" + + " `j` JSON NULL COMMENT \"\",\n" + + " `array` ARRAY<int(11)> NULL COMMENT \"\",\n" + + " `STRUCT` STRUCT<s_id:int(11), s_name:string, s_address:string> NULL COMMENT \"\"\n" + + " )\n" + + " DUPLICATE KEY(`user_id`, `username`)\n" + + " DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" + + " PROPERTIES (\n" + + " \"replication_allocation\" = \"tag.location.default: 1\"\n" + + " );" + + initTableData = "insert into ${tbName1} values(123456789, 'Alice', 1.83, 'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 100, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (234567890, 'Bob', 1.89, 'Shanghai', 30, 1, 13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00', {'a': 200, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (345678901, 'Carol', 2.6689, 'Guangzhou', 28, 0, 13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00', {'a': 300, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (456789012, 'Dave', 3.9456, 'Shenzhen', 35, 1, 13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00', {'a': 400, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (567890123, 'Eve', 4.223, 'Chengdu', 27, 0, 13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00', {'a': 500, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (678901234, 'Frank', 2.5454, 'Hangzhou', 32, 1, 13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00', {'a': 600, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}), " + + " (789012345, 'Grace', 2.19656, 'Xian', 29, 0, 13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'});" + + //TODO Test the dup model by modify a value type from STRUCT to BOOLEAN + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT BOOLEAN """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], false); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + // TODO Test the dup model by modify a value type from STRUCT to TINYINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT TINYINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.2, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 1); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from STRUCT to SMALLINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT SMALLINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 21); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from STRUCT to INT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT INT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 4.1, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 21); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from STRUCT to BIGINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT BIGINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 32454); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //Test the dup model by modify a value type from STRUCT to LARGEINT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT LARGEINT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 2.36, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 34235); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from STRUCT to FLOAT + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT FLOAT """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 45.5); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //TODO Test the dup model by modify a value type from STRUCT to DECIMAL + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT DECIMAL(38,0) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 1.23, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], 677.908); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from STRUCT to DATE + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT DATE """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.6, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], '2023-10-23'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from STRUCT to DATEV2 + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT DATEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.3, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], '2023-10-23'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //TODO Test the dup model by modify a value type from STRUCT to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT DATETIME """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 9.63, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], '2023-10-23 15:00:26'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + //TODO Test the dup model by modify a value type from STRUCT to DATETIME + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT DATETIMEV2 """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], '2023-10-26 15:54:21'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + + }, errorMessage) + + + //Test the dup model by modify a value type from STRUCT to VARCHAR + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT VARCHAR(100) """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 5.69, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], "ertet"); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from STRUCT to STRING + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT STRING """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 6.59, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], "wrwerew"); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, false, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from STRUCT to JSON + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT JSON """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\\\"abc\\\", \\\"def\\\"]', [6,7,8], {'a': 700, 'b': 200}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + //Test the dup model by modify a value type from STRUCT to MAP + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT Map<STRING, INT> """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], '[\"abc\", \"def\"]'); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + + + //Test the dup model by modify a value type from STRUCT to ARRAY + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ + sql initTable + sql initTableData + sql """ alter table ${tbName1} MODIFY column STRUCT ARRAY<int(11)> """ + insertSql = "insert into ${tbName1} values(923456689, 'Alice', 8.47, 'yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]', [6,7,8], {1, 'sn1', 'sa1'}); " + waitForSchemaChangeDone({ + sql getTableStatusSql + time 600 + }, insertSql, true, "${tbName1}") + }, errorMessage) + +} diff --git a/regression-test/suites/schema_change_p0/test_unique_schema_value_modify3.groovy b/regression-test/suites/schema_change_p0/test_unique_schema_value_modify3.groovy index dc847249ba0..9387d66802a 100644 --- a/regression-test/suites/schema_change_p0/test_unique_schema_value_modify3.groovy +++ b/regression-test/suites/schema_change_p0/test_unique_schema_value_modify3.groovy @@ -90,8 +90,8 @@ suite("test_unique_schema_value_modify3", "p0") { " (789012345, 'Grace', 2.19656, 'Xian', 29, 0, 13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00', {'a': 700, 'b': 200}, '[\"abc\", \"def\"]');" //TODO Test the unique model by modify a value type from MAP to BOOLEAN - errorMessage = "errCode = 2, detailMessage = Can not change MAP to BOOLEAN" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m BOOLEAN """ @@ -104,8 +104,8 @@ suite("test_unique_schema_value_modify3", "p0") { // TODO Test the unique model by modify a value type from MAP to TINYINT - errorMessage = "errCode = 2, detailMessage = Can not change MAP to TINYINT" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m TINYINT """ @@ -118,8 +118,8 @@ suite("test_unique_schema_value_modify3", "p0") { //Test the unique model by modify a value type from MAP to SMALLINT - errorMessage = "errCode = 2, detailMessage = Can not change MAP to SMALLINT" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m SMALLINT """ @@ -132,8 +132,8 @@ suite("test_unique_schema_value_modify3", "p0") { }, errorMessage) //Test the unique model by modify a value type from MAP to INT - errorMessage = "errCode = 2, detailMessage = Can not change MAP to INT" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m INT """ @@ -147,8 +147,8 @@ suite("test_unique_schema_value_modify3", "p0") { //Test the unique model by modify a value type from MAP to BIGINT - errorMessage = "errCode = 2, detailMessage = Can not change MAP to BIGINT" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m BIGINT """ @@ -161,8 +161,8 @@ suite("test_unique_schema_value_modify3", "p0") { }, errorMessage) //Test the unique model by modify a value type from MAP to LARGEINT - errorMessage = "errCode = 2, detailMessage = Can not change MAP to LARGEINT" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m LARGEINT """ @@ -175,8 +175,8 @@ suite("test_unique_schema_value_modify3", "p0") { //Test the unique model by modify a value type from MAP to FLOAT - errorMessage = "errCode = 2, detailMessage = Can not change MAP to FLOAT" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m FLOAT """ @@ -189,8 +189,8 @@ suite("test_unique_schema_value_modify3", "p0") { //TODO Test the unique model by modify a value type from MAP to DECIMAL - errorMessage = "errCode = 2, detailMessage = Can not change MAP to DECIMAL128" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m DECIMAL(38,0) """ @@ -204,8 +204,8 @@ suite("test_unique_schema_value_modify3", "p0") { //TODO Test the unique model by modify a value type from MAP to DATE - errorMessage = "errCode = 2, detailMessage = Can not change MAP to DATEV2" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m DATE """ @@ -218,8 +218,8 @@ suite("test_unique_schema_value_modify3", "p0") { }, errorMessage) //TODO Test the unique model by modify a value type from MAP to DATEV2 - errorMessage = "errCode = 2, detailMessage = Can not change MAP to DATEV2" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m DATEV2 """ @@ -233,8 +233,8 @@ suite("test_unique_schema_value_modify3", "p0") { //TODO Test the unique model by modify a value type from MAP to DATETIME - errorMessage = "errCode = 2, detailMessage = Can not change MAP to DATETIMEV2" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m DATETIME """ @@ -247,8 +247,8 @@ suite("test_unique_schema_value_modify3", "p0") { }, errorMessage) //TODO Test the unique model by modify a value type from MAP to DATETIME - errorMessage = "errCode = 2, detailMessage = Can not change MAP to DATETIMEV2" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m DATETIMEV2 """ @@ -262,8 +262,8 @@ suite("test_unique_schema_value_modify3", "p0") { //Test the unique model by modify a value type from MAP to VARCHAR - errorMessage = "errCode = 2, detailMessage = Can not change MAP to VARCHAR" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m VARCHAR(100) """ @@ -275,8 +275,8 @@ suite("test_unique_schema_value_modify3", "p0") { }, errorMessage) //Test the unique model by modify a value type from MAP to STRING - errorMessage = "errCode = 2, detailMessage = Can not change MAP to STRING" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m STRING """ @@ -288,8 +288,8 @@ suite("test_unique_schema_value_modify3", "p0") { }, errorMessage) //Test the unique model by modify a value type from MAP to JSON - errorMessage = "errCode = 2, detailMessage = Can not change MAP to JSON" - expectException({ + errorMessage = "errCode = 2, detailMessage = Can not change" + expectExceptionLike({ sql initTable sql initTableData sql """ alter table ${tbName} MODIFY column m JSON """ --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org