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 8025da22745 branch-4.1:[fix](sync) Treat empty cancel alter job list 
as all rollup jobs (#62712) (#62965)
8025da22745 is described below

commit 8025da22745813829dbed9476160a793d70af71d
Author: seawinde <[email protected]>
AuthorDate: Fri May 1 10:32:24 2026 +0800

    branch-4.1:[fix](sync) Treat empty cancel alter job list as all rollup jobs 
(#62712) (#62965)
    
    pr: #62712
    commitId: ce5a468c8e0
---
 .../doris/alter/MaterializedViewHandler.java       |  2 +-
 .../org/apache/doris/alter/RollupJobV2Test.java    | 27 ++++++++++++++++++++++
 .../doris/nereids/parser/NereidsParserTest.java    | 10 ++++++++
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java 
b/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
index 90569f3d2f1..2a318726edd 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java
@@ -1336,7 +1336,7 @@ public class MaterializedViewHandler extends AlterHandler 
{
             }
 
             // find from new alter jobs first
-            if (command.getAlterJobIdList() != null) {
+            if (command.getAlterJobIdList() != null && 
!command.getAlterJobIdList().isEmpty()) {
                 for (Long jobId : command.getAlterJobIdList()) {
                     AlterJobV2 alterJobV2 = 
getUnfinishedAlterJobV2ByJobId(jobId);
                     if (alterJobV2 == null) {
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/alter/RollupJobV2Test.java 
b/fe/fe-core/src/test/java/org/apache/doris/alter/RollupJobV2Test.java
index b95d055a94c..f46e9599042 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/alter/RollupJobV2Test.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/alter/RollupJobV2Test.java
@@ -42,7 +42,9 @@ import org.apache.doris.common.FeConstants;
 import org.apache.doris.common.FeMetaVersion;
 import org.apache.doris.common.UserException;
 import org.apache.doris.common.jmockit.Deencapsulation;
+import org.apache.doris.info.TableNameInfo;
 import org.apache.doris.meta.MetaContext;
+import org.apache.doris.nereids.trees.plans.commands.CancelAlterTableCommand;
 import org.apache.doris.qe.OriginStatement;
 import org.apache.doris.task.AgentTask;
 import org.apache.doris.task.AgentTaskQueue;
@@ -164,6 +166,31 @@ public class RollupJobV2Test {
         Assert.assertEquals(OlapTableState.ROLLUP, olapTable.getState());
     }
 
+    @Test
+    public void testCancelRollupWithEmptyJobIdList() throws Exception {
+        fakeEnv = new FakeEnv();
+        fakeEditLog = new FakeEditLog();
+        FakeEnv.setEnv(masterEnv);
+        MaterializedViewHandler materializedViewHandler = 
Env.getCurrentEnv().getMaterializedViewHandler();
+
+        ArrayList<AlterClause> alterClauses = new ArrayList<>();
+        alterClauses.add(clause);
+        Database db = 
masterEnv.getInternalCatalog().getDbOrDdlException(CatalogTestUtil.testDbId1);
+        OlapTable olapTable = (OlapTable) 
db.getTableOrDdlException(CatalogTestUtil.testTableId1);
+        materializedViewHandler.process(alterClauses, db, olapTable);
+        Map<Long, AlterJobV2> alterJobsV2 = 
materializedViewHandler.getAlterJobsV2();
+        Assert.assertEquals(1, alterJobsV2.size());
+
+        RollupJobV2 rollupJob = (RollupJobV2) 
alterJobsV2.values().stream().findAny().get();
+        CancelAlterTableCommand cancelAlterTableCommand = new 
CancelAlterTableCommand(
+                new TableNameInfo(db.getFullName(), olapTable.getName()),
+                CancelAlterTableCommand.AlterType.ROLLUP,
+                Lists.newArrayList());
+        materializedViewHandler.cancel(cancelAlterTableCommand);
+
+        Assert.assertEquals(JobState.CANCELLED, rollupJob.getJobState());
+    }
+
     // start a schema change, then finished
     @Test
     public void testSchemaChange1() throws Exception {
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
index 977177161fd..062ba47b1b5 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
@@ -39,6 +39,7 @@ import org.apache.doris.nereids.trees.plans.DistributeType;
 import org.apache.doris.nereids.trees.plans.JoinType;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.commands.CancelAlterTableCommand;
 import 
org.apache.doris.nereids.trees.plans.commands.CreateMaterializedViewCommand;
 import org.apache.doris.nereids.trees.plans.commands.CreateTableCommand;
 import org.apache.doris.nereids.trees.plans.commands.CreateViewCommand;
@@ -120,6 +121,15 @@ public class NereidsParserTest extends ParserTestBase {
                 .assertMessageEquals("\nextraneous input 'illegal_symbol' 
expecting {<EOF>, ';'}(line 1, pos 29)\n");
     }
 
+    @Test
+    public void testCancelAlterTableWithoutJobIdsBuildsEmptyJobIdList() {
+        NereidsParser nereidsParser = new NereidsParser();
+        Plan plan = nereidsParser.parseSingle("CANCEL ALTER TABLE ROLLUP FROM 
db1.tbl1");
+        Assertions.assertInstanceOf(CancelAlterTableCommand.class, plan);
+        CancelAlterTableCommand command = (CancelAlterTableCommand) plan;
+        Assertions.assertTrue(command.getAlterJobIdList().isEmpty());
+    }
+
     @Test
     public void testPostProcessor() {
         parsePlan("select `AD``D` from t1 where a = 1")


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

Reply via email to