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 aa7853472ec106d..7e79f92d0f29695 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 @@ -1161,9 +1161,6 @@ private boolean checkLightSchemaChange(OlapTable olapTable, Column newColumn, return lightSchemaChange; } - long baseIndexId = olapTable.getBaseIndexId(); - Set baseColumnNames = Sets.newHashSet(); - // check light schema change with add key column for (Long alterIndexId : indexSchemaMap.keySet()) { List alterSchema = indexSchemaMap.get(alterIndexId); @@ -1181,20 +1178,6 @@ private boolean checkLightSchemaChange(OlapTable olapTable, Column newColumn, return false; } - // not support add key column for mv index - if (alterIndexId != baseIndexId) { - if (baseColumnNames.isEmpty()) { - for (Column col : olapTable.getBaseSchemaKeyColumns()) { - baseColumnNames.add(col.getName()); - } - } - for (Column col : olapTable.getKeyColumnsByIndexId(alterIndexId)) { - if (null != col.getDefineExpr() || !baseColumnNames.contains(col.getName())) { - return false; - } - } - } - // unique key merge on write if (olapTable.getEnableUniqueKeyMergeOnWrite()) { return false; diff --git a/regression-test/suites/schema_change_p0/test_add_keys_light_schema_change.groovy b/regression-test/suites/schema_change_p0/test_add_keys_light_schema_change.groovy index 2dcdefc85ea2200..4f8c14dfaa82fe9 100644 --- a/regression-test/suites/schema_change_p0/test_add_keys_light_schema_change.groovy +++ b/regression-test/suites/schema_change_p0/test_add_keys_light_schema_change.groovy @@ -127,9 +127,9 @@ suite ("test_add_keys_light_schema_change") { """ jobStateResult = waitJobFinish(""" SHOW ALTER TABLE COLUMN WHERE IndexName='add_keys_light_schema_change' ORDER BY createtime DESC LIMIT 1 """, 9) - assertNotEquals(jobStateResult[0][8], "-1") + assertEquals(jobStateResult[0][8], "-1") jobStateResult = waitJobFinish(""" SHOW ALTER TABLE COLUMN WHERE IndexName='first_view' ORDER BY createtime DESC LIMIT 1 """, 9) - assertNotEquals(jobStateResult[0][8], "-1") + assertEquals(jobStateResult[0][8], "-1") sql """ ALTER TABLE add_keys_light_schema_change ADD COLUMN new_mv_key2 INT default "2" @@ -204,9 +204,6 @@ suite ("test_add_keys_light_schema_change") { (1, '2017-10-01', 'Beijing', 10, 1, 1, 1, 40, hll_hash(3), to_bitmap(3)) """ table_tablets = sql """ SHOW TABLETS FROM add_keys_light_schema_change ORDER BY RowCount DESC LIMIT 1 """ - rowset_cnt = sql """ SELECT count(*) FROM information_schema.rowsets WHERE TABLET_ID = ${table_tablets[0][0]} """ - log.info(JsonOutput.toJson(rowset_cnt)) - assertEquals(rowset_cnt[0][0], 4) qt_21_agg_multi_rowset """ SELECT user_id,sum(cost),max(max_dwell_time),hll_union_agg(hll_col),bitmap_union_count(bitmap_col) FROM add_keys_light_schema_change GROUP BY user_id; """ qt_21_agg_multi_rowset """ SELECT user_id,sum(cost),max(max_dwell_time),hll_union_agg(hll_col),bitmap_union_count(bitmap_col) FROM add_keys_light_schema_change WHERE new_key_column = 2 GROUP BY user_id; """ @@ -315,9 +312,6 @@ suite ("test_add_keys_light_schema_change") { (1, '2017-10-01', 'Beijing', 10, 1, 1, 1, 40, hll_hash(3), to_bitmap(3)) """ table_tablets = sql """ SHOW TABLETS FROM add_keys_light_schema_change WHERE IndexName = "add_keys_light_schema_change" ORDER BY RowCount DESC LIMIT 1 """ - rowset_cnt = sql """ SELECT count(*) FROM information_schema.rowsets WHERE TABLET_ID = ${table_tablets[0][0]} """ - log.info(JsonOutput.toJson(rowset_cnt)) - assertEquals(rowset_cnt[0][0], 4) qt_23_base_table_multi_rowset """ SELECT user_id,sum(cost),max(max_dwell_time),hll_union_agg(hll_col),bitmap_union_count(bitmap_col) FROM add_keys_light_schema_change GROUP BY user_id; """ qt_23_base_table_multi_rowset """ SELECT user_id,sum(cost),max(max_dwell_time),hll_union_agg(hll_col),bitmap_union_count(bitmap_col) FROM add_keys_light_schema_change WHERE new_key_column = 2 GROUP BY user_id; """ @@ -333,10 +327,7 @@ suite ("test_add_keys_light_schema_change") { table_tablets = sql """ SHOW TABLETS FROM add_keys_light_schema_change WHERE IndexName = "first_idx" ORDER BY RowCount DESC LIMIT 1 """ - rowset_cnt = sql """ SELECT count(*) FROM information_schema.rowsets WHERE TABLET_ID = ${table_tablets[0][0]} """ - log.info(JsonOutput.toJson(rowset_cnt)) - assertEquals(rowset_cnt[0][0], 4) qt_23_rollup_multi_rowset """ SELECT user_id,sum(cost) FROM add_keys_light_schema_change GROUP BY user_id; """ qt_23_rollup_multi_rowset """ SELECT user_id,sum(cost) FROM add_keys_light_schema_change WHERE new_key_column = 2 GROUP BY user_id; """ qt_23_rollup_multi_rowset """ SELECT user_id,sum(cost) FROM add_keys_light_schema_change WHERE new_key_column = 1 GROUP BY user_id; """ @@ -381,9 +372,6 @@ suite ("test_add_keys_light_schema_change") { ('2017-10-01 10:00:00', '1', 0, 1, 'none', 10, '2017-10-01 12:00:00') """ table_tablets = sql """ SHOW TABLETS FROM add_keys_light_schema_change ORDER BY RowCount DESC LIMIT 1 """ - rowset_cnt = sql """ SELECT count(*) FROM information_schema.rowsets WHERE TABLET_ID = ${table_tablets[0][0]} """ - log.info(JsonOutput.toJson(rowset_cnt)) - assertEquals(rowset_cnt[0][0], 4) qt_31_duplicate_multi_rowset """ SELECT * FROM add_keys_light_schema_change; """ qt_31_duplicate_multi_rowset """ SELECT * FROM add_keys_light_schema_change WHERE new_key_column = 2; """ @@ -432,9 +420,6 @@ suite ("test_add_keys_light_schema_change") { (1, 'Jone', 'Beijing', 1, 10, 1, 10010, 'Haidian', '2017-10-01 14:00:00') """ table_tablets = sql """ SHOW TABLETS FROM add_keys_light_schema_change ORDER BY RowCount DESC LIMIT 1 """ - rowset_cnt = sql """ SELECT count(*) FROM information_schema.rowsets WHERE TABLET_ID = ${table_tablets[0][0]} """ - log.info(JsonOutput.toJson(rowset_cnt)) - assertEquals(rowset_cnt[0][0], 4) qt_41_unique_multi_rowset """ SELECT * FROM add_keys_light_schema_change; """ qt_41_unique_multi_rowset """ SELECT * FROM add_keys_light_schema_change WHERE new_key_column = 2; """