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
commit 57a8c75ddccc239b92d359f1eb40f4888213a04a Author: Guangdong Liu <[email protected]> AuthorDate: Mon Jan 29 21:54:17 2024 +0800 [regression test](schema change) add case for column type change (#30472) --- .../test_schema_change_agg_check_all_types.out | 27 ++++ .../test_schema_change_agg_check_all_types.groovy | 170 ++++++++------------- 2 files changed, 88 insertions(+), 109 deletions(-) diff --git a/regression-test/data/schema_change_p0/test_schema_change_agg_check_all_types.out b/regression-test/data/schema_change_p0/test_schema_change_agg_check_all_types.out index 3f7a29b7cd5..6c309341860 100644 --- a/regression-test/data/schema_change_p0/test_schema_change_agg_check_all_types.out +++ b/regression-test/data/schema_change_p0/test_schema_change_agg_check_all_types.out @@ -32,3 +32,30 @@ 10005 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 1.1100000143051147 10006 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 1.11 +-- !add_float -- +10001 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0.0 0.0 +10002 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0.0 0.0 +10003 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0.0 0.0 +10004 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0.0 0.0 +10005 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0.0 1.1100000143051147 +10006 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0.0 1.11 +10007 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 1.11 1.21 + +-- !float_to_varchar -- +10001 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0 0.0 +10002 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0 0.0 +10003 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0 0.0 +10004 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0 0.0 +10005 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0 1.1100000143051147 +10006 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0 1.11 +10007 2 3 8 10 13.2 3.4 9 a b c 2021-10-30 2021-10-30T00:00 1.11 1.21 + +-- !varchar_to_float -- +10001 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0.0 0.0 +10002 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0.0 0.0 +10003 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0.0 0.0 +10004 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0.0 0.0 +10005 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0.0 1.1100000143051147 +10006 2 3 4 5 6.6 1.7 9 a b c 2021-10-30 2021-10-30T00:00 0.0 1.11 +10007 2 3 8 10 13.2 3.4 9 a b c 2021-10-30 2021-10-30T00:00 1.11 1.21 + diff --git a/regression-test/suites/schema_change_p0/test_schema_change_agg_check_all_types.groovy b/regression-test/suites/schema_change_p0/test_schema_change_agg_check_all_types.groovy index a23c9094163..8eb70bb4ddf 100644 --- a/regression-test/suites/schema_change_p0/test_schema_change_agg_check_all_types.groovy +++ b/regression-test/suites/schema_change_p0/test_schema_change_agg_check_all_types.groovy @@ -18,16 +18,6 @@ suite("test_schema_change_agg_check_all_types", "p0") { def tableName3 = "test_schema_change_agg_check_all_types" - def getJobState = { tableName -> - def jobStateResult = sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """ - return jobStateResult[0][9] - } - - def getCreateViewState = { tableName -> - def createViewStateResult = sql """ SHOW ALTER TABLE MATERIALIZED VIEW WHERE IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """ - return createViewStateResult[0][8] - } - sql """ DROP TABLE IF EXISTS ${tableName3} """ sql """ @@ -55,22 +45,12 @@ suite("test_schema_change_agg_check_all_types", "p0") { // tinyint to smallint sql """ alter table ${tableName3} modify column k2 smallint key NULL""" - sleep(10) - max_try_num = 60 - while (max_try_num--) { - String res = getJobState(tableName3) - if (res == "FINISHED" || res == "CANCELLED") { - assertEquals("FINISHED", res) - sleep(3000) - break - } else { - sleep(100) - if (max_try_num < 1){ - assertEquals(1,2) - } - } + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 60 } + sql """ insert into ${tableName3} values (10001, 2, 3, 4, 5, 6.6, 1.7, 8.8, 'a', 'b', 'c', '2021-10-30', '2021-10-30 00:00:00') """ @@ -79,20 +59,9 @@ suite("test_schema_change_agg_check_all_types", "p0") { // smallint to int sql """ alter table ${tableName3} modify column k2 int key NULL""" - sleep(10) - max_try_num = 60 - while (max_try_num--) { - String res = getJobState(tableName3) - if (res == "FINISHED" || res == "CANCELLED") { - assertEquals("FINISHED", res) - sleep(3000) - break - } else { - sleep(100) - if (max_try_num < 1){ - assertEquals(1,2) - } - } + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 60 } sql """ insert into ${tableName3} values (10002, 2, 3, 4, 5, 6.6, 1.7, 8.8, @@ -102,20 +71,10 @@ suite("test_schema_change_agg_check_all_types", "p0") { // int to bigint sql """ alter table ${tableName3} modify column k2 bigint key NULL""" - sleep(10) - max_try_num = 60 - while (max_try_num--) { - String res = getJobState(tableName3) - if (res == "FINISHED" || res == "CANCELLED") { - assertEquals("FINISHED", res) - sleep(3000) - break - } else { - sleep(100) - if (max_try_num < 1){ - assertEquals(1,2) - } - } + + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 60 } sql """ insert into ${tableName3} values (10003, 2, 3, 4, 5, 6.6, 1.7, 8.8, @@ -124,22 +83,11 @@ suite("test_schema_change_agg_check_all_types", "p0") { qt_int_to_bigint """ select * from ${tableName3} """ // bigint to largeint - sql """ alter table ${tableName3} modify column k2 largeint key NULL""" - sleep(10) - max_try_num = 60 - while (max_try_num--) { - String res = getJobState(tableName3) - if (res == "FINISHED" || res == "CANCELLED") { - assertEquals("FINISHED", res) - sleep(3000) - break - } else { - sleep(100) - if (max_try_num < 1){ - assertEquals(1,2) - } - } + + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 60 } sql """ insert into ${tableName3} values (10004, 2, 3, 4, 5, 6.6, 1.7, 8.8, @@ -150,37 +98,15 @@ suite("test_schema_change_agg_check_all_types", "p0") { // largeint to float sql """ alter table ${tableName3} add column k14 largeint replace not null default "0" after k13""" - sleep(10) - max_try_num = 60 - while (max_try_num--) { - String res = getJobState(tableName3) - if (res == "FINISHED" || res == "CANCELLED") { - assertEquals("FINISHED", res) - sleep(3000) - break - } else { - sleep(100) - if (max_try_num < 1){ - assertEquals(1,2) - } - } + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 60 } sql """ alter table ${tableName3} modify column k14 float replace not null default "0" after k13""" - sleep(10) - max_try_num = 60 - while (max_try_num--) { - String res = getJobState(tableName3) - if (res == "FINISHED" || res == "CANCELLED") { - assertEquals("FINISHED", res) - sleep(3000) - break - } else { - sleep(100) - if (max_try_num < 1){ - assertEquals(1,2) - } - } + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 60 } sql """ insert into ${tableName3} values (10005, 2, 3, 4, 5, 6.6, 1.7, 8.8, @@ -190,20 +116,9 @@ suite("test_schema_change_agg_check_all_types", "p0") { // float to double sql """ alter table ${tableName3} modify column k14 double replace not null default "0" after k13""" - sleep(10) - max_try_num = 60 - while (max_try_num--) { - String res = getJobState(tableName3) - if (res == "FINISHED" || res == "CANCELLED") { - assertEquals("FINISHED", res) - sleep(3000) - break - } else { - sleep(100) - if (max_try_num < 1){ - assertEquals(1,2) - } - } + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 60 } sql """ insert into ${tableName3} values (10006, 2, 3, 4, 5, 6.6, 1.7, 8.8, @@ -211,5 +126,42 @@ suite("test_schema_change_agg_check_all_types", "p0") { qt_float_to_double """ select * from ${tableName3} """ + + // float to decimal & string + sql """ alter table ${tableName3} add column float1 float replace not null default "0" after k13""" + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 60 + } + sql """ insert into ${tableName3} values (10007, 2, 3, 4, 5, 6.6, 1.7, 8.8, + 'a', 'b', 'c', '2021-10-30', '2021-10-30 00:00:00',1.11,1.21) """ + + qt_add_float""" select * from ${tableName3} """ + + sql """ alter table ${tableName3} modify column float1 varchar replace not null default "0" after k13""" + + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 60 + } + sql """ insert into ${tableName3} values (10007, 2, 3, 4, 5, 6.6, 1.7, 8.8, + 'a', 'b', 'c', '2021-10-30', '2021-10-30 00:00:00',1.11,'1.21') """ + qt_float_to_varchar""" select * from ${tableName3} """ + + + sql """ alter table ${tableName3} modify column float1 float replace not null default "0" after k13""" + waitForSchemaChangeDone { + sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName3}' ORDER BY createtime DESC LIMIT 1 """ + time 60 + } + + qt_varchar_to_float""" select * from ${tableName3} """ + + + test { + sql """ alter table ${tableName3} modify column float1 decimal(9, 2) replace not null default "0" after k13""" + exception "Can not change FLOAT to DECIMAL32" + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
