This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 4e260192757 branch-3.1: [fix](variant) building index on the variant 
column is prohibited #54777 (#54856)
4e260192757 is described below

commit 4e2601927572029dce7ccadecb0213e18ea8fcf1
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Aug 15 17:53:19 2025 +0800

    branch-3.1: [fix](variant) building index on the variant column is 
prohibited #54777 (#54856)
    
    Cherry-picked from #54777
    
    Co-authored-by: Sun Chenyang <[email protected]>
---
 .../java/org/apache/doris/alter/SchemaChangeHandler.java   | 14 ++++++++++++++
 .../variant_github_events_nonConcurrent_p2/load.groovy     |  6 ++----
 .../suites/variant_p0/with_index/var_index.groovy          |  6 ++----
 3 files changed, 18 insertions(+), 8 deletions(-)

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 eed7550759b..364cacab538 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
@@ -2180,6 +2180,20 @@ public class SchemaChangeHandler extends AlterHandler {
                         throw new DdlException("BUILD INDEX operation failed: 
No need to do it in cloud mode.");
                     }
 
+                    for (Column column : olapTable.getBaseSchema()) {
+                        if (!column.getType().isVariantType()) {
+                            continue;
+                        }
+                        // variant type column can not support for building 
index
+                        for (String indexColumn : index.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()) {
                         indexOnPartitions.put(index.getIndexId(), 
olapTable.getPartitionNames());
                     } else {
diff --git 
a/regression-test/suites/variant_github_events_nonConcurrent_p2/load.groovy 
b/regression-test/suites/variant_github_events_nonConcurrent_p2/load.groovy
index 5050f5fc7ec..4febb29d977 100644
--- a/regression-test/suites/variant_github_events_nonConcurrent_p2/load.groovy
+++ b/regression-test/suites/variant_github_events_nonConcurrent_p2/load.groovy
@@ -105,11 +105,9 @@ suite("regression_test_variant_github_events_p2", 
"nonConcurrent,p2"){
     load_json_data.call(table_name, """${getS3Url() + 
'/regression/gharchive.m/2022-11-07-23.json'}""")
 
     // BUILD INDEX
-    try {
+    test {
         sql """ BUILD INDEX idx_var ON  github_events"""
-    } 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"))
+        exception "The idx_var index can not be built on the v column, because 
it is a variant type column"
     }
 
     // // add bloom filter at the end of loading data
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 f57bd6915be..21b2f5f6f00 100644
--- a/regression-test/suites/variant_p0/with_index/var_index.groovy
+++ b/regression-test/suites/variant_p0/with_index/var_index.groovy
@@ -149,11 +149,9 @@ suite("regression_test_variant_var_index", "p0, 
nonConcurrent"){
                 properties("replication_num" = "1", "disable_auto_compaction" 
= "true", "inverted_index_storage_format" = "V1");
             """
             sql """ALTER TABLE var_index ADD INDEX idx_var(v) USING INVERTED"""
-            try {
+            test {
                 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"))
+                exception "The idx_var index can not be built on the v column, 
because it is a variant type column"
             }
         }
         


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to