This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 2ef136cad61 [fix](variant) building index on the variant column is
prohibited (#49159) (#50028)
2ef136cad61 is described below
commit 2ef136cad6170d5820906995c1294ad805444955
Author: Sun Chenyang <[email protected]>
AuthorDate: Wed Apr 16 17:52:56 2025 +0800
[fix](variant) building index on the variant column is prohibited (#49159)
(#50028)
pick from master #49159
---
.../apache/doris/alter/SchemaChangeHandler.java | 13 ++++++++++++
.../suites/variant_p0/with_index/var_index.groovy | 24 ++++++++++++++++++++++
2 files changed, 37 insertions(+)
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 5d553281266..f32c9162f57 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
@@ -2015,6 +2015,19 @@ public class SchemaChangeHandler extends AlterHandler {
index.setIndexId(existedIdx.getIndexId());
index.setColumns(existedIdx.getColumns());
index.setProperties(existedIdx.getProperties());
+ for (Column column : olapTable.getBaseSchema()) {
+ if (!column.getType().isVariantType()) {
+ continue;
+ }
+ // variant type column can not support for
building index
+ for (String indexColumn :
existedIdx.getColumns()) {
+ if
(column.getName().equalsIgnoreCase(indexColumn)) {
+ throw new DdlException("BUILD INDEX
operation failed: The "
+ + indexDef.getIndexName() + "
index can not be built on the "
+ + indexColumn + " column,
because it is a variant type column.");
+ }
+ }
+ }
if (indexDef.getPartitionNames().isEmpty()) {
invertedIndexOnPartitions.put(index.getIndexId(),
olapTable.getPartitionNames());
} else {
diff --git a/regression-test/suites/variant_p0/with_index/var_index.groovy
b/regression-test/suites/variant_p0/with_index/var_index.groovy
index 3cf09afb7cc..4a87090064a 100644
--- a/regression-test/suites/variant_p0/with_index/var_index.groovy
+++ b/regression-test/suites/variant_p0/with_index/var_index.groovy
@@ -108,4 +108,28 @@ suite("regression_test_variant_var_index", "p0,
nonConcurrent"){
set disable_inverted_index_v1_for_variant = true
"""
+ try {
+ sql """ build index idx_var on var_index"""
+ } catch (Exception e) {
+ log.info(e.getMessage())
+ assertTrue(e.getMessage().contains("The idx_var index can not be built
on the v column, because it is a variant type column"))
+ }
+
+ sql "DROP TABLE IF EXISTS var_index"
+ sql """
+ CREATE TABLE IF NOT EXISTS var_index (
+ k bigint,
+ v variant
+ )
+ DUPLICATE KEY(`k`)
+ DISTRIBUTED BY HASH(k) BUCKETS 1
+ properties("replication_num" = "1", "disable_auto_compaction" =
"true", "inverted_index_storage_format" = "V2");
+ """
+ sql """ALTER TABLE var_index ADD INDEX idx_var(v) USING INVERTED"""
+ try {
+ sql """ build index idx_var on var_index"""
+ } catch (Exception e) {
+ log.info(e.getMessage())
+ assertTrue(e.getMessage().contains("The idx_var index can not be built
on the v column, because it is a variant type column"))
+ }
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]