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

airborne12 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 059f56dcf27 [fix](fe) Reject multi-column NGRAM_BF indexes (#64343)
059f56dcf27 is described below

commit 059f56dcf27c4823b3be45360c5cb4f57ee2c0cb
Author: Jack <[email protected]>
AuthorDate: Fri Jun 12 18:18:29 2026 +0800

    [fix](fe) Reject multi-column NGRAM_BF indexes (#64343)
    
    ### What problem does this PR solve?
    
    Related PR: None
    
    Problem Summary:
    
    Creating an NGRAM_BF index with multiple columns passed FE validation
    and could reach BE tablet creation, where tablet metadata expects each
    NGRAM_BF index to bind exactly one column. This rejects invalid
    multi-column NGRAM_BF definitions during FE analysis for both inline
    table indexes and CREATE INDEX.
    
    ### Release note
    
    Reject invalid multi-column NGRAM_BF index definitions during DDL
    analysis.
---
 .../trees/plans/commands/info/IndexDefinition.java |  5 +--
 .../trees/plans/commands/IndexDefinitionTest.java  | 15 +++++++++
 .../index_p0/test_ngram_bloomfilter_index.groovy   | 37 ++++++++++++++++++++++
 3 files changed, 55 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/IndexDefinition.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/IndexDefinition.java
index d1ae4d260b1..8630d80b7dc 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/IndexDefinition.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/IndexDefinition.java
@@ -344,7 +344,7 @@ public class IndexDefinition {
         if (partitionNames != null) {
             partitionNames.validate();
         }
-        if (isBuildDeferred && indexType == IndexType.INVERTED) {
+        if (isBuildDeferred && (indexType == IndexType.INVERTED || indexType 
== IndexType.NGRAM_BF)) {
             if (Strings.isNullOrEmpty(name)) {
                 throw new AnalysisException("index name cannot be blank.");
             }
@@ -359,7 +359,8 @@ public class IndexDefinition {
             AnnIndexPropertiesChecker.checkProperties(this.properties);
         }
 
-        if (indexType == IndexType.BITMAP || indexType == IndexType.INVERTED) {
+        if (indexType == IndexType.BITMAP || indexType == IndexType.INVERTED
+                || indexType == IndexType.NGRAM_BF) {
             if (cols == null || cols.size() != 1) {
                 throw new AnalysisException(
                         indexType.toString() + " index can only apply to a 
single column.");
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/IndexDefinitionTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/IndexDefinitionTest.java
index 837bdd0ddfa..7b41ddc95cf 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/IndexDefinitionTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/IndexDefinitionTest.java
@@ -19,6 +19,7 @@ package org.apache.doris.nereids.trees.plans.commands;
 
 import org.apache.doris.catalog.AggregateType;
 import org.apache.doris.catalog.KeysType;
+import org.apache.doris.catalog.info.IndexType;
 import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.trees.plans.commands.info.ColumnDefinition;
 import org.apache.doris.nereids.trees.plans.commands.info.IndexDefinition;
@@ -136,6 +137,20 @@ public class IndexDefinitionTest {
                 KeysType.DUP_KEYS, false, null);
     }
 
+    @Test
+    void testNgramBFIndexOnlySingleColumn() {
+        IndexDefinition def = new IndexDefinition("ngram_bf_index", false, 
Lists.newArrayList("col1", "col2"),
+                "NGRAM_BF", null, "comment");
+        AnalysisException exception = 
Assertions.assertThrows(AnalysisException.class, def::validate);
+        Assertions.assertEquals("NGRAM_BF index can only apply to a single 
column.", exception.getMessage());
+    }
+
+    @Test
+    void testNgramBFBuildIndexValidateWithoutColumns() {
+        IndexDefinition def = new IndexDefinition("ngram_bf_index", null, 
IndexType.NGRAM_BF);
+        Assertions.assertDoesNotThrow(def::validate);
+    }
+
     @Test
     void testInvalidNgramBFIndexColumnType() {
         Map<String, String> properties = new HashMap<>();
diff --git 
a/regression-test/suites/index_p0/test_ngram_bloomfilter_index.groovy 
b/regression-test/suites/index_p0/test_ngram_bloomfilter_index.groovy
index 5bcd55e96f4..05e77400b55 100644
--- a/regression-test/suites/index_p0/test_ngram_bloomfilter_index.groovy
+++ b/regression-test/suites/index_p0/test_ngram_bloomfilter_index.groovy
@@ -110,4 +110,41 @@ suite("test_ngram_bloomfilter_index") {
         sql """ALTER TABLE  ${tableName3} ADD INDEX idx_http_url(http_url) 
USING NGRAM_BF PROPERTIES("gram_size"="256", "bf_size"="65535") COMMENT 
'http_url ngram_bf index'"""
         exception "java.sql.SQLException: errCode = 2, detailMessage = 
'gram_size' should be an integer between 1 and 255."
     }
+
+    sql "DROP TABLE IF EXISTS test_ngram_bloomfilter_multi_column_index"
+    test {
+        sql """
+        CREATE TABLE test_ngram_bloomfilter_multi_column_index (
+            `key_id` bigint(20) NULL COMMENT '',
+            `http_url` text NULL COMMENT '',
+            `url_path` varchar(2000) NULL COMMENT '',
+            INDEX idx_ngrambf_multi (`http_url`, `url_path`) USING NGRAM_BF
+                PROPERTIES("gram_size" = "2", "bf_size" = "512")
+        ) ENGINE=OLAP
+        DUPLICATE KEY(`key_id`)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(`key_id`) BUCKETS 1
+        PROPERTIES("replication_num" = "1");
+        """
+        exception "NGRAM_BF index can only apply to a single column."
+    }
+
+    sql """
+        CREATE TABLE test_ngram_bloomfilter_multi_column_index (
+            `key_id` bigint(20) NULL COMMENT '',
+            `http_url` text NULL COMMENT '',
+            `url_path` varchar(2000) NULL COMMENT ''
+        ) ENGINE=OLAP
+        DUPLICATE KEY(`key_id`)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(`key_id`) BUCKETS 1
+        PROPERTIES("replication_num" = "1");
+        """
+    test {
+        sql """
+        CREATE INDEX idx_ngrambf_multi ON 
test_ngram_bloomfilter_multi_column_index(`http_url`, `url_path`)
+            USING NGRAM_BF PROPERTIES("gram_size" = "2", "bf_size" = "512")
+        """
+        exception "NGRAM_BF index can only apply to a single column."
+    }
 }


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

Reply via email to