[BugFix] Fix incompatible bitmap index reuse for fast schema evolution in shared-data (backport #63315) (#63415)
Signed-off-by: PengFei Li <lpengfei2016@gmail.com> Co-authored-by: PengFei Li <lpengfei2016@gmail.com>
This commit is contained in:
parent
79a69a8b67
commit
079adbaa8f
|
|
@ -914,7 +914,23 @@ public class SchemaChangeHandler extends AlterHandler {
|
|||
}
|
||||
|
||||
if (!SchemaChangeTypeCompatibility.canReuseZonemapIndex(oriColumn.getType(), modColumn.getType())) {
|
||||
fastSchemaEvolution = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check whether manually created indexes support fast schema evolution. The rules are as follows:
|
||||
// 1. The index can be reused after type conversion, and BE has made necessary changes,
|
||||
// such as casting new type values to old type values before querying the index.
|
||||
// 2. The index cannot be reused, and BE has made changes to skip it during queries.
|
||||
// Currently, BLOOMFILTER and NGRAMBF indexes use rule 2 to support fast schema evolution. BE-side changes
|
||||
// for other indexes are not yet ready, so fast schema change is temporarily disabled for them. This feature
|
||||
// will be gradually enabled for these indexes once BE support is in place.
|
||||
List<Index> existedIndexes = olapTable.getIndexes();
|
||||
for (Index index : existedIndexes) {
|
||||
if (index.getColumns().contains(oriColumn.getColumnId())) {
|
||||
if (index.getIndexType() != IndexDef.IndexType.NGRAMBF) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fastSchemaEvolution;
|
||||
|
|
|
|||
|
|
@ -521,4 +521,36 @@ public class LakeTableAsyncFastSchemaChangeJobTest extends StarRocksTestBase {
|
|||
createAggTableForAddKeyColumnTest(tableName);
|
||||
testAddKeyColumnWithoutFastSchemaEvolutionBase(tableName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testModifyColumnTypeWithManuallyCreatedIndex() throws Exception {
|
||||
LakeTable table = createTable(connectContext,
|
||||
"""
|
||||
CREATE TABLE t_modify_index_type (
|
||||
c0 INT,
|
||||
c1 INT,
|
||||
c2 INT,
|
||||
INDEX idx1 (c1) USING BITMAP
|
||||
)
|
||||
DUPLICATE KEY(c0)
|
||||
DISTRIBUTED BY HASH(c0) BUCKETS 1
|
||||
PROPERTIES(
|
||||
'fast_schema_evolution'='true',
|
||||
'bloom_filter_columns' = 'c2'
|
||||
)
|
||||
"""
|
||||
);
|
||||
|
||||
// bitmap index can not use fast schema evolution
|
||||
{
|
||||
String alterSql = "ALTER TABLE t_modify_index_type MODIFY COLUMN c1 BIGINT";
|
||||
executeAlterAndWaitFinish(table, alterSql, false);
|
||||
}
|
||||
|
||||
// bloomfilter index can use fast schema evolution
|
||||
{
|
||||
String alterSql = "ALTER TABLE t_modify_index_type MODIFY COLUMN c2 BIGINT";
|
||||
executeAlterAndWaitFinish(table, alterSql, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue