This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push: new ce342d0cece [cherry-pick](schema-change) Forbid modifying mv related columns (#48328) ce342d0cece is described below commit ce342d0cecef967744d1877f0f5ea9e0c034300e Author: Siyang Tang <tangsiyang2...@foxmail.com> AuthorDate: Thu Feb 27 17:59:32 2025 +0800 [cherry-pick](schema-change) Forbid modifying mv related columns (#48328) ### What problem does this PR solve? pick: #47271 ### Release note None ### Check List (For Author) - Test <!-- At least one of them must be included. --> - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [ ] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [ ] No. - [ ] Yes. <!-- Add document PR link here. eg: https://github.com/apache/doris-website/pull/1214 --> ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into --> --- .../apache/doris/alter/SchemaChangeHandler.java | 9 ++++---- .../schema_change_modify_mv_column_type_agg.out | Bin 2634 -> 1366 bytes .../schema_change_modify_mv_column_type.out | Bin 9551 -> 7289 bytes .../schema_change_modify_mv_column_type2.out | Bin 7682 -> 6355 bytes .../routine_load_mapping.groovy | 13 +++-------- .../schema_change_modify_mv_column_type_agg.groovy | 23 +++---------------- .../schema_change_modify_mv_column_type.groovy | 25 +++------------------ .../schema_change_modify_mv_column_type2.groovy | 25 +++------------------ 8 files changed, 16 insertions(+), 79 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java index 674cbdae61f..42c2f4c2ebb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java @@ -25,7 +25,6 @@ import org.apache.doris.analysis.CancelAlterTableStmt; import org.apache.doris.analysis.CancelStmt; import org.apache.doris.analysis.ColumnPosition; import org.apache.doris.analysis.CreateIndexClause; -import org.apache.doris.analysis.CreateMaterializedViewStmt; import org.apache.doris.analysis.DropColumnClause; import org.apache.doris.analysis.DropIndexClause; import org.apache.doris.analysis.Expr; @@ -712,8 +711,8 @@ public class SchemaChangeHandler extends AlterHandler { for (Column column : schema) { String columnName = column.getName(); if (column.isMaterializedViewColumn()) { - columnName = MaterializedIndexMeta.normalizeName( - CreateMaterializedViewStmt.mvColumnBreaker(columnName)); + throw new DdlException("Can not modify column contained by mv, mv=" + + olapTable.getIndexNameById(entry.getKey())); } if (columnName.equalsIgnoreCase(modColumn.getName())) { otherIndexIds.add(entry.getKey()); @@ -729,8 +728,8 @@ public class SchemaChangeHandler extends AlterHandler { Column col = otherIndexSchema.get(i); String columnName = col.getName(); if (col.isMaterializedViewColumn()) { - columnName = MaterializedIndexMeta.normalizeName( - CreateMaterializedViewStmt.mvColumnBreaker(columnName)); + throw new DdlException("Can not modify column contained by mv, mv=" + + olapTable.getIndexNameById(otherIndexId)); } if (!columnName.equalsIgnoreCase(modColumn.getName())) { continue; diff --git a/regression-test/data/schema_change_p0/modify_col_type_agg/schema_change_modify_mv_column_type_agg.out b/regression-test/data/schema_change_p0/modify_col_type_agg/schema_change_modify_mv_column_type_agg.out index b1feac9a13a..7ab1e73e5f8 100644 Binary files a/regression-test/data/schema_change_p0/modify_col_type_agg/schema_change_modify_mv_column_type_agg.out and b/regression-test/data/schema_change_p0/modify_col_type_agg/schema_change_modify_mv_column_type_agg.out differ diff --git a/regression-test/data/schema_change_p0/modify_col_type_dup/schema_change_modify_mv_column_type.out b/regression-test/data/schema_change_p0/modify_col_type_dup/schema_change_modify_mv_column_type.out index 3503eca2085..2c3de71bc3d 100644 Binary files a/regression-test/data/schema_change_p0/modify_col_type_dup/schema_change_modify_mv_column_type.out and b/regression-test/data/schema_change_p0/modify_col_type_dup/schema_change_modify_mv_column_type.out differ diff --git a/regression-test/data/schema_change_p0/modify_col_type_dup2/schema_change_modify_mv_column_type2.out b/regression-test/data/schema_change_p0/modify_col_type_dup2/schema_change_modify_mv_column_type2.out index 57100b6dd41..024ed9d867e 100644 Binary files a/regression-test/data/schema_change_p0/modify_col_type_dup2/schema_change_modify_mv_column_type2.out and b/regression-test/data/schema_change_p0/modify_col_type_dup2/schema_change_modify_mv_column_type2.out differ diff --git a/regression-test/suites/mv_p0/routine_load_mapping/routine_load_mapping.groovy b/regression-test/suites/mv_p0/routine_load_mapping/routine_load_mapping.groovy index ca3a3560e01..320224ad513 100644 --- a/regression-test/suites/mv_p0/routine_load_mapping/routine_load_mapping.groovy +++ b/regression-test/suites/mv_p0/routine_load_mapping/routine_load_mapping.groovy @@ -104,15 +104,8 @@ PROPERTIES ( heart_type = 1 ;""") - sql """ ALTER TABLE rt_new MODIFY COLUMN event_id VARCHAR(51) NULL;""" - Thread.sleep(1000) - - streamLoad { - table "rt_new" - set 'column_separator', ',' - set 'columns', '`battery_id`,`create_time`,`imei`,`event_id`,`event_name`,`heart_type`' - - file './test2' - time 10000 // limit inflight 10s + test { + sql """ ALTER TABLE rt_new MODIFY COLUMN event_id VARCHAR(51) NULL;""" + exception "Can not modify column contained by mv" } } diff --git a/regression-test/suites/schema_change_p0/modify_col_type_agg/schema_change_modify_mv_column_type_agg.groovy b/regression-test/suites/schema_change_p0/modify_col_type_agg/schema_change_modify_mv_column_type_agg.groovy index dd5cc5c47ee..b4be34c76f6 100644 --- a/regression-test/suites/schema_change_p0/modify_col_type_agg/schema_change_modify_mv_column_type_agg.groovy +++ b/regression-test/suites/schema_change_p0/modify_col_type_agg/schema_change_modify_mv_column_type_agg.groovy @@ -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}" } diff --git a/regression-test/suites/schema_change_p0/modify_col_type_dup/schema_change_modify_mv_column_type.groovy b/regression-test/suites/schema_change_p0/modify_col_type_dup/schema_change_modify_mv_column_type.groovy index 92c3870c563..bd9d95dbf86 100644 --- a/regression-test/suites/schema_change_p0/modify_col_type_dup/schema_change_modify_mv_column_type.groovy +++ b/regression-test/suites/schema_change_p0/modify_col_type_dup/schema_change_modify_mv_column_type.groovy @@ -74,27 +74,8 @@ suite("schema_change_modify_mv_column_type") { 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}" } diff --git a/regression-test/suites/schema_change_p0/modify_col_type_dup2/schema_change_modify_mv_column_type2.groovy b/regression-test/suites/schema_change_p0/modify_col_type_dup2/schema_change_modify_mv_column_type2.groovy index 0346a661162..2f475992b49 100644 --- a/regression-test/suites/schema_change_p0/modify_col_type_dup2/schema_change_modify_mv_column_type2.groovy +++ b/regression-test/suites/schema_change_p0/modify_col_type_dup2/schema_change_modify_mv_column_type2.groovy @@ -74,27 +74,8 @@ suite("schema_change_modify_mv_column_type2") { 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}" } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org