Skip to content

Commit ca674b2

Browse files
authored
[fix](variant) building index on the variant column is prohibited (#49159)
Index files are not created for variant columns during the build index process, causing link file operations to fail
1 parent 14723c6 commit ca674b2

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,6 +2117,19 @@ public int getAsInt() {
21172117
+ existedIdx.getIndexName() + " of type " + existedIdx.getIndexType()
21182118
+ " does not support lightweight index changes.");
21192119
}
2120+
for (Column column : olapTable.getBaseSchema()) {
2121+
if (!column.getType().isVariantType()) {
2122+
continue;
2123+
}
2124+
// variant type column can not support for building index
2125+
for (String indexColumn : existedIdx.getColumns()) {
2126+
if (column.getName().equalsIgnoreCase(indexColumn)) {
2127+
throw new DdlException("BUILD INDEX operation failed: The "
2128+
+ indexDef.getIndexName() + " index can not be built on the "
2129+
+ indexColumn + " column, because it is a variant type column.");
2130+
}
2131+
}
2132+
}
21202133
index = existedIdx.clone();
21212134
if (indexDef.getPartitionNames().isEmpty()) {
21222135
invertedIndexOnPartitions.put(index.getIndexId(), olapTable.getPartitionNames());

regression-test/suites/variant_p0/with_index/var_index.groovy

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,29 @@ suite("regression_test_variant_var_index", "p0, nonConcurrent"){
106106
"""
107107
sql """ALTER TABLE var_index ADD INDEX idx_var(v) USING INVERTED"""
108108
sql """ set disable_inverted_index_v1_for_variant = true """
109+
110+
try {
111+
sql """ build index idx_var on var_index"""
112+
} catch (Exception e) {
113+
log.info(e.getMessage())
114+
assertTrue(e.getMessage().contains("The idx_var index can not be built on the v column, because it is a variant type column"))
115+
}
116+
117+
sql "DROP TABLE IF EXISTS var_index"
118+
sql """
119+
CREATE TABLE IF NOT EXISTS var_index (
120+
k bigint,
121+
v variant
122+
)
123+
DUPLICATE KEY(`k`)
124+
DISTRIBUTED BY HASH(k) BUCKETS 1
125+
properties("replication_num" = "1", "disable_auto_compaction" = "true", "inverted_index_storage_format" = "V2");
126+
"""
127+
sql """ALTER TABLE var_index ADD INDEX idx_var(v) USING INVERTED"""
128+
try {
129+
sql """ build index idx_var on var_index"""
130+
} catch (Exception e) {
131+
log.info(e.getMessage())
132+
assertTrue(e.getMessage().contains("The idx_var index can not be built on the v column, because it is a variant type column"))
133+
}
109134
}

0 commit comments

Comments
 (0)