Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](schema-change) Forbid modifying mv related columns #47271

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
fix cases
TangSiyang2001 committed Jan 24, 2025
commit 316d6e49a527d8a56fb4ea714ecba8fc5a284d71
Original file line number Diff line number Diff line change
@@ -28,28 +28,3 @@ mv_tbl_scalar_types_agg_1 AGG_KEYS mv_k2 bigint bigint Yes true \N true `k2`

-- !sql --

-- !master_sql --
tbl_scalar_types_agg AGG_KEYS k1 bigint bigint Yes true \N true
k2 bigint bigint Yes true \N true
c_bool boolean boolean Yes false \N REPLACE true
c_tinyint tinyint tinyint Yes false \N MIN true
c_smallint smallint smallint Yes false \N MAX true
c_int bigint bigint Yes false \N MAX true
c_bigint bigint bigint Yes false \N SUM true
c_largeint largeint largeint Yes false \N MIN true
c_float float float Yes false \N MIN true
c_double double double Yes false \N MAX true
c_decimal DECIMAL(20, 3) decimalv3(20,3) Yes false \N SUM true
c_decimalv3 DECIMAL(20, 3) decimalv3(20,3) Yes false \N SUM true
c_date DATE datev2 Yes false \N REPLACE true
c_datetime DATETIME datetimev2(0) Yes false \N REPLACE true
c_datev2 DATE datev2 Yes false \N REPLACE true
c_datetimev2 DATETIME datetimev2(0) Yes false \N REPLACE true
c_char char(15) char(15) Yes false \N REPLACE true
c_varchar varchar(100) varchar(100) Yes false \N REPLACE true
c_string text text Yes false \N REPLACE true

mv_tbl_scalar_types_agg_1 AGG_KEYS mv_k2 bigint bigint Yes true \N true `k2`
mv_k1 bigint bigint Yes true \N true `k1`
mva_MAX__`c_int` bigint bigint Yes false \N MAX true `c_int`

Original file line number Diff line number Diff line change
@@ -62,42 +62,3 @@ mv_tbl_scalar_types_dup_1 DUP_KEYS mv_c_tinyint tinyint tinyint Yes true \N tru
-2106969609 true 10 29572 16738 1736115820 -957295886 -13319.206 -1.333603562816737E9 91224478600376111.942 69457425159617037.453 2022-09-06 2022-05-08T19:52:36 2022-04-05 2022-08-17T19:23:31 222.79.139.99 [email protected] Oxford Alley 77
-2102307005 true 10 -23674 24613 -1810828490 -47095409 -14686.167 2.072108685694799E9 39847820962230526.125 584354832299375.156 2022-03-27 2022-02-11T13:46:06 2022-12-25 2022-11-28T09:37:49 213.146.33.250 [email protected] Eagle Crest Terrace 84

-- !master_sql --
tbl_scalar_types_dup DUP_KEYS k1 bigint bigint Yes true \N true
c_bool boolean boolean Yes false \N NONE true
c_tinyint tinyint tinyint Yes false \N NONE true
c_smallint smallint smallint Yes false \N NONE true
c_int bigint bigint Yes false \N NONE true
c_bigint bigint bigint Yes false \N NONE true
c_largeint largeint largeint Yes false \N NONE true
c_float float float Yes false \N NONE true
c_double double double Yes false \N NONE true
c_decimal DECIMAL(20, 3) decimalv3(20,3) Yes false \N NONE true
c_decimalv3 DECIMAL(20, 3) decimalv3(20,3) Yes false \N NONE true
c_date DATE datev2 Yes false \N NONE true
c_datetime DATETIME datetimev2(0) Yes false \N NONE true
c_datev2 DATE datev2 Yes false \N NONE true
c_datetimev2 DATETIME datetimev2(0) Yes false \N NONE true
c_char char(15) char(15) Yes false \N NONE true
c_varchar varchar(100) varchar(100) Yes false \N NONE true
c_string text text Yes false \N NONE true

mv_tbl_scalar_types_dup_1 DUP_KEYS mv_c_tinyint tinyint tinyint Yes true \N true `c_tinyint`
mv_c_bool boolean boolean Yes true \N true `c_bool`
mv_k1 bigint bigint Yes true \N true `k1`
mv_c_smallint smallint smallint Yes false \N NONE true `c_smallint`
mv_c_int bigint bigint Yes false \N NONE true `c_int`
mv_c_bigint bigint bigint Yes false \N NONE true `c_bigint`
mv_c_largeint largeint largeint Yes false \N NONE true `c_largeint`
mv_c_float float float Yes false \N NONE true `c_float`
mv_c_double double double Yes false \N NONE true `c_double`
mv_c_decimal DECIMAL(20, 3) decimalv3(20,3) Yes false \N NONE true `c_decimal`
mv_c_decimalv3 DECIMAL(20, 3) decimalv3(20,3) Yes false \N NONE true `c_decimalv3`
mv_c_date DATE datev2 Yes false \N NONE true `c_date`
mv_c_datetime DATETIME datetimev2(0) Yes false \N NONE true `c_datetime`
mv_c_datev2 DATE datev2 Yes false \N NONE true `c_datev2`
mv_c_datetimev2 DATETIME datetimev2(0) Yes false \N NONE true `c_datetimev2`
mv_c_char character(255) character(255) Yes false \N NONE true `c_char`
mv_c_varchar varchar(65533) varchar(65533) Yes false \N NONE true `c_varchar`
mv_c_string text text Yes false \N NONE true `c_string`

Original file line number Diff line number Diff line change
@@ -73,25 +73,8 @@ suite("schema_change_modify_mv_column_type_agg") {
qt_sql "SELECT * from ${testTable} order by 1, 2, 3 limit 10"
qt_sql "SELECT * from ${testTable} where c_tinyint = 10 order by 1, 2, 3 limit 10 "

sql """
ALTER table ${testTable} MODIFY COLUMN c_int BIGINT max;
"""
def getJobState = { tableName ->
def jobStateResult = sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """
return jobStateResult[0][9]
}
int max_try_time = 100
while (max_try_time--){
String result = getJobState(testTable)
if (result == "FINISHED") {
break
} else {
sleep(2000)
if (max_try_time < 1){
assertEquals(1,2)
}
}
test {
sql """ ALTER table ${testTable} MODIFY COLUMN c_int BIGINT max """
exception "Can not modify column contained by mv"
}
qt_master_sql """ desc ${testTable} all """
sql "INSERT INTO ${testTable} SELECT * from ${testTable}"
}
Original file line number Diff line number Diff line change
@@ -73,28 +73,8 @@ suite("schema_change_modify_mv_column_type") {
sql "set topn_opt_limit_threshold = 100"
qt_sql "SELECT * from ${testTable} order by 1, 2, 3 limit 10"
qt_sql "SELECT * from ${testTable} where c_tinyint = 10 order by 1, 2, 3 limit 10 "

sql """
ALTER table ${testTable} MODIFY COLUMN c_int BIGINT;
"""
def getJobState = { tableName ->
def jobStateResult = sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """
return jobStateResult[0][9]
}
int max_try_time = 100
while (max_try_time--){
String result = getJobState(testTable)
if (result == "FINISHED") {
break
} else {
sleep(2000)
if (max_try_time < 1){
assertEquals(1,2)
}
}
test {
sql "ALTER table ${testTable} MODIFY COLUMN c_int BIGINT;"
exception "Can not modify column contained by mv"
}
// sync materialized view rewrite will fail when schema change, tmp disable, enable when fixed
sql """set enable_dml_materialized_view_rewrite = false;"""
qt_master_sql """ desc ${testTable} all """
sql "INSERT INTO ${testTable} SELECT * from ${testTable}"
}