Skip to content

Commit

Permalink
light schema change add key support mv
Browse files Browse the repository at this point in the history
  • Loading branch information
wangqingtao6 committed Nov 8, 2024
1 parent 98197ee commit ec7d59a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1161,9 +1161,6 @@ private boolean checkLightSchemaChange(OlapTable olapTable, Column newColumn,
return lightSchemaChange;
}

long baseIndexId = olapTable.getBaseIndexId();
Set<String> baseColumnNames = Sets.newHashSet();

// check light schema change with add key column
for (Long alterIndexId : indexSchemaMap.keySet()) {
List<Column> alterSchema = indexSchemaMap.get(alterIndexId);
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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; """
Expand Down Expand Up @@ -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; """
Expand All @@ -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; """
Expand Down Expand Up @@ -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; """
Expand Down Expand Up @@ -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; """
Expand Down

0 comments on commit ec7d59a

Please sign in to comment.