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

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


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new 1eeac703d0c branch-4.1: [fix](cloud) Reject DROP INDEX ON PARTITION in 
cloud mode #71041 (#71042)
1eeac703d0c is described below

commit 1eeac703d0cf5427f29be8f65ce0c5f38759b41c
Author: Jack <[email protected]>
AuthorDate: Sun Nov 29 18:30:11 2026 +0800

    branch-4.1: [fix](cloud) Reject DROP INDEX ON PARTITION in cloud mode 
#71041 (#71042)
    
    ### What problem does this PR solve?
    
    Issue Number: None
    
    Related PR: #71041 (master fix, open; this pick follows any change it
    gets in review), #70357 (brought DROP INDEX ON PARTITION to branch-4.1)
    
    Problem Summary:
    
    Pick of #71041 (commit 83809891202) to branch-4.1.
    
    In cloud mode, `DROP INDEX ... ON PARTITION` and `ALTER TABLE ... DROP
    INDEX ... PARTITION` report success and their job reaches FINISHED, but
    the index stays: the cloud index-change task ignores `is_drop_op` and
    only rewrites rowsets older than the table's schema version, and a
    partition drop keeps that version. Cloud mode cannot hold a rowset
    schema that differs from the table schema at the same schema version, so
    this change rejects both statements in cloud mode with "DROP INDEX ON
    PARTITION is not supported in cloud mode". Shared-nothing mode and
    whole-table `DROP INDEX` are unchanged. See #71041 for the end-to-end
    reproduction on a cloud cluster.
    
    Hunk audit against the source diff:
    
    | File | Source hunk | Result |
    |---|---|---|
    | `DropIndexOp.java` | `@@ -21,6 +21,7 @@ import
    org.apache.doris.alter.AlterOpType;` | Ported |
    | `DropIndexOp.java` | `@@ -101,6 +102,11 @@ public class DropIndexOp
    extends AlterTableOp {` | Ported |
    | `IndexChangeJobTest.java` | `@@ -1058,6 +1058,25 @@ public class
    IndexChangeJobTest {` | Adapted: this branch's file uses JUnit 4
    `Assert` and did not import `Config`, so the test imports it and uses
    the try/`Assert.fail`/catch form of its neighbours with the same checks
    |
    | `test_drop_index_on_partition.groovy` | `@@ -51,6 +51,37 @@
    suite("test_drop_index_on_partition", "inverted_index") {` | Ported,
    after this branch's helpers |
    | `test_cloud_build_index_on_partition.groovy`, `.out` | new files |
    Ported (verbatim) |
    
    ### Release note
    
    In cloud mode, `DROP INDEX ... ON PARTITION` and `ALTER TABLE ... DROP
    INDEX ... PARTITION` now fail with "DROP INDEX ON PARTITION is not
    supported in cloud mode". Before, they reported success but kept the
    index on the named partitions. Drop the index from the whole table
    instead.
    
    ### Check List (For Author)
    
    - Test
        - [x] Regression test
        - [x] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [ ] No need to test or manual test.
    
    Run locally on this branch: `./run-fe-ut.sh --run
    
org.apache.doris.alter.IndexChangeJobTest,org.apache.doris.alter.CloudIndexTest,org.apache.doris.alter.SchemaChangeHandlerTest`
    passed (19, 5 and 30 tests). With the `DropIndexOp` check removed,
    `IndexChangeJobTest#testDropIndexOnPartitionRejectedInCloudMode` fails
    with "DROP INDEX ON PARTITION must be rejected in cloud mode".
    Merge-tree FE Checkstyle passed. The regression changes are cloud-only
    (the cloud branch of `test_drop_index_on_partition` and the new
    `test_cloud_build_index_on_partition`); they were run on a master cloud
    cluster in #71041. On this branch, cloud_p0 build 13215 at 42343e92ff4
    ran both: its FE log shows the cloud DROP table with no index job, and
    BUILD jobs for p1 and then p2 only; the build passed with 0 failures of
    4789 tests.
    
    - Behavior changed:
        - [ ] No.
    - [x] Yes. In cloud mode the two partition-drop statement forms now fail
    at analysis instead of reporting a drop that did not happen.
    
    - Does this need documentation?
    - [x] No. The DROP INDEX page in apache/doris-website does not document
    the ON PARTITION form.
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
---
 .../trees/plans/commands/info/DropIndexOp.java     |  6 ++
 .../org/apache/doris/alter/IndexChangeJobTest.java | 21 +++++++
 .../test_cloud_build_index_on_partition.out        | 19 ++++++
 .../test_cloud_build_index_on_partition.groovy     | 72 ++++++++++++++++++++++
 .../test_drop_index_on_partition.groovy            | 31 ++++++++++
 5 files changed, 149 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropIndexOp.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropIndexOp.java
index 3c233604cbb..9b8a05465f1 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropIndexOp.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropIndexOp.java
@@ -21,6 +21,7 @@ import org.apache.doris.alter.AlterOpType;
 import org.apache.doris.analysis.AlterTableClause;
 import org.apache.doris.analysis.DropIndexClause;
 import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.Config;
 import org.apache.doris.common.UserException;
 import org.apache.doris.info.PartitionNamesInfo;
 import org.apache.doris.info.TableNameInfo;
@@ -103,6 +104,11 @@ public class DropIndexOp extends AlterTableOp {
             tableName.analyze(ctx);
         }
         if (partitionNamesInfo != null) {
+            // Cloud mode keeps one rowset schema per schema version, so it 
cannot drop an index from
+            // only some partitions while the table schema keeps it.
+            if (Config.isCloudMode()) {
+                throw new AnalysisException("DROP INDEX ON PARTITION is not 
supported in cloud mode");
+            }
             if (partitionNamesInfo.isTemp()) {
                 throw new AnalysisException(
                         "DROP INDEX ON PARTITION does not support temporary 
partitions");
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/alter/IndexChangeJobTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/alter/IndexChangeJobTest.java
index be9f6a678b7..8daa4506771 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/alter/IndexChangeJobTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/alter/IndexChangeJobTest.java
@@ -37,6 +37,7 @@ import org.apache.doris.catalog.Partition.PartitionState;
 import org.apache.doris.catalog.Replica;
 import org.apache.doris.catalog.Tablet;
 import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.Config;
 import org.apache.doris.common.DdlException;
 import org.apache.doris.common.FeConstants;
 import org.apache.doris.common.FeMetaVersion;
@@ -843,6 +844,26 @@ public class IndexChangeJobTest {
         Assert.assertEquals(normalPartition.getPartitionNames(), 
clause.getPartitionNames());
     }
 
+    @Test
+    public void testDropIndexOnPartitionRejectedInCloudMode() throws Exception 
{
+        PartitionNamesInfo partition = new PartitionNamesInfo(false, 
Lists.newArrayList("p1"));
+        DropIndexOp partitionDrop = new DropIndexOp("index1", false, null, 
true, partition);
+        DropIndexOp tableDrop = new DropIndexOp("index1", false, null, true, 
null);
+        String originalCloudUniqueId = Config.cloud_unique_id;
+        try {
+            Config.cloud_unique_id = "test_cloud_drop_index_on_partition";
+            // Dropping the index from the whole table still works in cloud 
mode.
+            tableDrop.validate(new ConnectContext());
+            partitionDrop.validate(new ConnectContext());
+            Assert.fail("DROP INDEX ON PARTITION must be rejected in cloud 
mode");
+        } catch (AnalysisException e) {
+            Assert.assertTrue(e.getMessage(),
+                    e.getMessage().contains("DROP INDEX ON PARTITION is not 
supported in cloud mode"));
+        } finally {
+            Config.cloud_unique_id = originalCloudUniqueId;
+        }
+    }
+
     @Test
     public void testDropIndexOnPartitionRejectsNonPartitionedTable() throws 
UserException {
         // testTable1 uses SinglePartitionInfo (non-partitioned), so DROP 
INDEX ON PARTITION should fail
diff --git 
a/regression-test/data/inverted_index_p0/cloud_build_index/test_cloud_build_index_on_partition.out
 
b/regression-test/data/inverted_index_p0/cloud_build_index/test_cloud_build_index_on_partition.out
new file mode 100644
index 00000000000..5dd30656884
--- /dev/null
+++ 
b/regression-test/data/inverted_index_p0/cloud_build_index/test_cloud_build_index_on_partition.out
@@ -0,0 +1,19 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+1      aaaaa
+
+-- !sql --
+101    aaaaa
+
+-- !sql --
+1      aaaaa
+
+-- !sql --
+101    aaaaa
+
+-- !sql --
+1      aaaaa
+
+-- !sql --
+101    aaaaa
+
diff --git 
a/regression-test/suites/inverted_index_p0/cloud_build_index/test_cloud_build_index_on_partition.groovy
 
b/regression-test/suites/inverted_index_p0/cloud_build_index/test_cloud_build_index_on_partition.groovy
new file mode 100644
index 00000000000..83f90b19344
--- /dev/null
+++ 
b/regression-test/suites/inverted_index_p0/cloud_build_index/test_cloud_build_index_on_partition.groovy
@@ -0,0 +1,72 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// In cloud mode, BUILD INDEX ON PARTITION builds the index only for the named 
partitions.
+suite("test_cloud_build_index_on_partition") {
+    if (!isCloudMode()) {
+        return
+    }
+
+    def timeout = 60000
+
+    // With a light CREATE INDEX, rows loaded before the index get it only 
from BUILD INDEX.
+    sql "set enable_add_index_for_new_data = true"
+    sql "set enable_profile = true"
+    sql "set profile_level = 2"
+
+    sql "DROP TABLE IF EXISTS test_cloud_build_index_on_partition"
+    sql """
+        CREATE TABLE test_cloud_build_index_on_partition (
+            k1 int NOT NULL,
+            v1 varchar(50) NOT NULL
+        )
+        DUPLICATE KEY(`k1`)
+        PARTITION BY RANGE(`k1`) (
+            PARTITION p1 VALUES LESS THAN (100),
+            PARTITION p2 VALUES LESS THAN (200)
+        )
+        DISTRIBUTED BY HASH(`k1`) BUCKETS 1
+    """
+    sql """
+        INSERT INTO test_cloud_build_index_on_partition VALUES
+        (1, 'aaaaa'), (2, 'bbbbb'), (3, 'ccccc'),
+        (101, 'aaaaa'), (102, 'bbbbb'), (103, 'ccccc')
+    """
+
+    def p1_query = "SELECT * FROM test_cloud_build_index_on_partition WHERE k1 
< 100 AND v1 = 'aaaaa'"
+    def p2_query = "SELECT * FROM test_cloud_build_index_on_partition WHERE k1 
>= 100 AND v1 = 'aaaaa'"
+
+    sql "CREATE INDEX idx_v1 ON test_cloud_build_index_on_partition(v1) USING 
INVERTED"
+    check_inverted_index_filter_rows(p1_query, 0)
+    check_inverted_index_filter_rows(p2_query, 0)
+
+    // SHOW BUILD INDEX also lists jobs of earlier tables with this name, so 
compare counts.
+    def show_p2_jobs = """SHOW BUILD INDEX WHERE TableName = 
"test_cloud_build_index_on_partition" AND PartitionName = "p2";"""
+    def p2_job_count = sql(show_p2_jobs).size()
+
+    // Each partition holds three rows and one match, so a built index filters 
two rows.
+    sql "BUILD INDEX ON test_cloud_build_index_on_partition PARTITION (p1)"
+    wait_for_last_build_index_finish("test_cloud_build_index_on_partition", 
timeout)
+    assertEquals(p2_job_count, sql(show_p2_jobs).size())
+    check_inverted_index_filter_rows(p1_query, 2)
+    check_inverted_index_filter_rows(p2_query, 0)
+
+    sql "BUILD INDEX ON test_cloud_build_index_on_partition PARTITION (p2)"
+    wait_for_last_build_index_finish("test_cloud_build_index_on_partition", 
timeout)
+    check_inverted_index_filter_rows(p1_query, 2)
+    check_inverted_index_filter_rows(p2_query, 2)
+}
diff --git 
a/regression-test/suites/inverted_index_p0/index_change/test_drop_index_on_partition.groovy
 
b/regression-test/suites/inverted_index_p0/index_change/test_drop_index_on_partition.groovy
index 3ebdb824a59..6fe9b2deca4 100644
--- 
a/regression-test/suites/inverted_index_p0/index_change/test_drop_index_on_partition.groovy
+++ 
b/regression-test/suites/inverted_index_p0/index_change/test_drop_index_on_partition.groovy
@@ -42,6 +42,37 @@ suite("test_drop_index_on_partition", "inverted_index") {
         assertTrue(finished, "Index change jobs did not finish within 
${OpTimeout} ms for ${table_name}")
     }
 
+    // Cloud mode stores one rowset schema per schema version, so it cannot 
drop an index from only
+    // some partitions and rejects the statement before creating any job.
+    if (isCloudMode()) {
+        sql "DROP TABLE IF EXISTS test_drop_idx_on_partition_cloud"
+        sql """
+            CREATE TABLE test_drop_idx_on_partition_cloud (
+                k1 int NOT NULL,
+                v1 varchar(50),
+                INDEX idx_v1 (v1) USING INVERTED
+            )
+            DUPLICATE KEY(`k1`)
+            PARTITION BY RANGE(`k1`) (
+                PARTITION p1 VALUES LESS THAN (100),
+                PARTITION p2 VALUES LESS THAN (200)
+            )
+            DISTRIBUTED BY HASH(`k1`) BUCKETS 1
+        """
+        // SHOW BUILD INDEX also lists jobs of earlier tables with this name, 
so compare counts.
+        def cloud_job_count = 
get_build_index_job_count("test_drop_idx_on_partition_cloud")
+        test {
+            sql "DROP INDEX idx_v1 ON test_drop_idx_on_partition_cloud 
PARTITION (p1)"
+            exception "DROP INDEX ON PARTITION is not supported in cloud mode"
+        }
+        test {
+            sql "ALTER TABLE test_drop_idx_on_partition_cloud DROP INDEX 
idx_v1 PARTITION (p1)"
+            exception "DROP INDEX ON PARTITION is not supported in cloud mode"
+        }
+        assertEquals(cloud_job_count, 
get_build_index_job_count("test_drop_idx_on_partition_cloud"))
+        return
+    }
+
     // case 1: basic DROP INDEX ON PARTITION with job count verification
     def tableName1 = "test_drop_idx_on_partition_basic"
     sql "DROP TABLE IF EXISTS ${tableName1}"


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

Reply via email to