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

starocean999 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 738d0bf1cd7 [feat](Nereids) support alter job status commands (#44279)
738d0bf1cd7 is described below

commit 738d0bf1cd774946dca7c90d4839cf4579e07fc6
Author: LiBinfeng <[email protected]>
AuthorDate: Thu Nov 21 14:56:03 2024 +0800

    [feat](Nereids) support alter job status commands (#44279)
---
 .../antlr4/org/apache/doris/nereids/DorisParser.g4 | 13 +--
 .../doris/nereids/parser/LogicalPlanBuilder.java   | 52 ++++++++++++
 .../apache/doris/nereids/trees/plans/PlanType.java |  4 +
 .../plans/commands/AlterJobStatusCommand.java      | 98 +++++++++++++++++++++
 .../trees/plans/commands/CancelJobTaskCommand.java | 99 ++++++++++++++++++++++
 .../trees/plans/commands/DropJobCommand.java       | 51 +++++++++++
 .../trees/plans/commands/PauseJobCommand.java      | 50 +++++++++++
 .../trees/plans/commands/ResumeJobCommand.java     | 50 +++++++++++
 .../trees/plans/visitor/CommandVisitor.java        | 25 ++++++
 9 files changed, 433 insertions(+), 9 deletions(-)

diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
index 97932c3bb2a..cc7ade25fb2 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
@@ -76,7 +76,6 @@ unsupportedStatement
     | unsupportedAdminStatement
     | unsupportedTransactionStatement
     | unsupportedCancelStatement
-    | unsupportedJobStatement
     | unsupportedCleanStatement
     | unsupportedRefreshStatement
     | unsupportedLoadStatement
@@ -117,6 +116,10 @@ supportedJobStatement
             (AT (atTime=STRING_LITERAL | CURRENT_TIMESTAMP)))
         commentSpec?
         DO supportedDmlStatement                                               
                #createScheduledJob                                             
                       
+   | PAUSE JOB wildWhere?                                                      
                #pauseJob
+   | DROP JOB (IF EXISTS)? wildWhere?                                          
                #dropJob
+   | RESUME JOB wildWhere?                                                     
                #resumeJob
+   | CANCEL TASK wildWhere?                                                    
                #cancelJobTask
    ;
 constraintStatement
     : ALTER TABLE table=multipartIdentifier
@@ -437,14 +440,6 @@ unsupportedCleanStatement
     | CLEAN ALL QUERY STATS                                                    
     #cleanAllQueryStats
     ;
 
-unsupportedJobStatement
-
-    : PAUSE JOB wildWhere?                                                     
     #pauseJob
-    | DROP JOB (IF EXISTS)? wildWhere?                                         
     #dropJob
-    | RESUME JOB wildWhere?                                                    
     #resumeJob
-    | CANCEL TASK wildWhere?                                                   
     #cancelJobTask
-    ;
-
 unsupportedCancelStatement
     : CANCEL LOAD ((FROM | IN) database=identifier)? wildWhere?                
     #cancelLoad
     | CANCEL EXPORT ((FROM | IN) database=identifier)? wildWhere?              
     #cancelExport
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 36b25e474df..00cc011ef23 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -421,6 +421,7 @@ import 
org.apache.doris.nereids.trees.plans.commands.AlterRoleCommand;
 import org.apache.doris.nereids.trees.plans.commands.AlterStorageVaultCommand;
 import org.apache.doris.nereids.trees.plans.commands.AlterViewCommand;
 import org.apache.doris.nereids.trees.plans.commands.CallCommand;
+import org.apache.doris.nereids.trees.plans.commands.CancelJobTaskCommand;
 import org.apache.doris.nereids.trees.plans.commands.CancelMTMVTaskCommand;
 import org.apache.doris.nereids.trees.plans.commands.Command;
 import org.apache.doris.nereids.trees.plans.commands.Constraint;
@@ -436,6 +437,7 @@ import 
org.apache.doris.nereids.trees.plans.commands.DeleteFromUsingCommand;
 import 
org.apache.doris.nereids.trees.plans.commands.DropCatalogRecycleBinCommand;
 import 
org.apache.doris.nereids.trees.plans.commands.DropCatalogRecycleBinCommand.IdType;
 import org.apache.doris.nereids.trees.plans.commands.DropConstraintCommand;
+import org.apache.doris.nereids.trees.plans.commands.DropJobCommand;
 import org.apache.doris.nereids.trees.plans.commands.DropMTMVCommand;
 import org.apache.doris.nereids.trees.plans.commands.DropProcedureCommand;
 import org.apache.doris.nereids.trees.plans.commands.DropRoleCommand;
@@ -444,12 +446,14 @@ import 
org.apache.doris.nereids.trees.plans.commands.ExplainCommand;
 import 
org.apache.doris.nereids.trees.plans.commands.ExplainCommand.ExplainLevel;
 import org.apache.doris.nereids.trees.plans.commands.ExportCommand;
 import org.apache.doris.nereids.trees.plans.commands.LoadCommand;
+import org.apache.doris.nereids.trees.plans.commands.PauseJobCommand;
 import org.apache.doris.nereids.trees.plans.commands.PauseMTMVCommand;
 import org.apache.doris.nereids.trees.plans.commands.RecoverDatabaseCommand;
 import org.apache.doris.nereids.trees.plans.commands.RecoverPartitionCommand;
 import org.apache.doris.nereids.trees.plans.commands.RecoverTableCommand;
 import org.apache.doris.nereids.trees.plans.commands.RefreshMTMVCommand;
 import org.apache.doris.nereids.trees.plans.commands.ReplayCommand;
+import org.apache.doris.nereids.trees.plans.commands.ResumeJobCommand;
 import org.apache.doris.nereids.trees.plans.commands.ResumeMTMVCommand;
 import 
org.apache.doris.nereids.trees.plans.commands.SetDefaultStorageVaultCommand;
 import org.apache.doris.nereids.trees.plans.commands.SetOptionsCommand;
@@ -676,6 +680,43 @@ public class LogicalPlanBuilder extends 
DorisParserBaseVisitor<Object> {
         return new CreateJobCommand(createJobInfo);
     }
 
+    @Override
+    public LogicalPlan visitPauseJob(DorisParser.PauseJobContext ctx) {
+        Expression wildWhere = null;
+        if (ctx.wildWhere() != null) {
+            wildWhere = getWildWhere(ctx.wildWhere());
+        }
+        return new PauseJobCommand(wildWhere);
+    }
+
+    @Override
+    public LogicalPlan visitDropJob(DorisParser.DropJobContext ctx) {
+        Expression wildWhere = null;
+        if (ctx.wildWhere() != null) {
+            wildWhere = getWildWhere(ctx.wildWhere());
+        }
+        boolean ifExists = ctx.EXISTS() != null;
+        return new DropJobCommand(wildWhere, ifExists);
+    }
+
+    @Override
+    public LogicalPlan visitResumeJob(DorisParser.ResumeJobContext ctx) {
+        Expression wildWhere = null;
+        if (ctx.wildWhere() != null) {
+            wildWhere = getWildWhere(ctx.wildWhere());
+        }
+        return new ResumeJobCommand(wildWhere);
+    }
+
+    @Override
+    public LogicalPlan visitCancelJobTask(DorisParser.CancelJobTaskContext 
ctx) {
+        Expression wildWhere = null;
+        if (ctx.wildWhere() != null) {
+            wildWhere = getWildWhere(ctx.wildWhere());
+        }
+        return new CancelJobTaskCommand(wildWhere);
+    }
+
     @Override
     public String visitCommentSpec(DorisParser.CommentSpecContext ctx) {
         String commentSpec = ctx == null ? "''" : 
ctx.STRING_LITERAL().getText();
@@ -4138,6 +4179,17 @@ public class LogicalPlanBuilder extends 
DorisParserBaseVisitor<Object> {
         }
     }
 
+    private Expression getWildWhere(DorisParser.WildWhereContext ctx) {
+        if (ctx.LIKE() != null) {
+            String pattern = stripQuotes(ctx.STRING_LITERAL().getText());
+            return new Like(new UnboundSlot("ProcedureName"), new 
StringLiteral(pattern));
+        } else if (ctx.WHERE() != null) {
+            return getExpression(ctx.expression());
+        } else {
+            throw new AnalysisException("Wild where should contain like or 
where " + ctx.getText());
+        }
+    }
+
     @Override
     public ShowViewCommand visitShowView(ShowViewContext ctx) {
         List<String> tableNameParts = visitMultipartIdentifier(ctx.tableName);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PlanType.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PlanType.java
index e040d18b82f..ccfb505624b 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PlanType.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PlanType.java
@@ -145,6 +145,10 @@ public enum PlanType {
     UPDATE_COMMAND,
     CREATE_MTMV_COMMAND,
     CREATE_JOB_COMMAND,
+    PAUSE_JOB_COMMAND,
+    CANCEL_JOB_COMMAND,
+    DROP_JOB_COMMAND,
+    RESUME_JOB_COMMAND,
     ALTER_MTMV_COMMAND,
     ADD_CONSTRAINT_COMMAND,
     DROP_CONSTRAINT_COMMAND,
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterJobStatusCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterJobStatusCommand.java
new file mode 100644
index 00000000000..c3aafa8a5fe
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/AlterJobStatusCommand.java
@@ -0,0 +1,98 @@
+// 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.
+
+package org.apache.doris.nereids.trees.plans.commands;
+
+import org.apache.doris.analysis.StmtType;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.ErrorCode;
+import org.apache.doris.common.ErrorReport;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+import org.apache.doris.nereids.analyzer.UnboundSlot;
+import org.apache.doris.nereids.trees.expressions.EqualTo;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.literal.StringLikeLiteral;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.StmtExecutor;
+
+import com.google.common.base.Strings;
+
+/**
+ * base class for all drop commands
+ */
+public abstract class AlterJobStatusCommand extends Command implements 
ForwardWithSync {
+    // exclude job name prefix, which is used by inner job
+    private static final String excludeJobNamePrefix = "inner_";
+    private final Expression wildWhere;
+    private String jobName;
+
+    public AlterJobStatusCommand(PlanType type, Expression wildWhere) {
+        super(type);
+        this.wildWhere = wildWhere;
+    }
+
+    public String getJobName() {
+        return jobName;
+    }
+
+    @Override
+    public StmtType stmtType() {
+        return StmtType.ALTER;
+    }
+
+    @Override
+    public void run(ConnectContext ctx, StmtExecutor executor) throws 
Exception {
+        validate();
+        doRun(ctx, executor);
+    }
+
+    @Override
+    public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
+        return visitor.visitAlterJobStatusCommand(this, context);
+    }
+
+    private void validate() throws Exception {
+        if (!(wildWhere instanceof EqualTo)) {
+            throw new AnalysisException("Alter job status only support equal 
condition, but not: " + wildWhere.toSql());
+        }
+        if 
(!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), 
PrivPredicate.ADMIN)) {
+            
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, 
"ADMIN");
+        }
+        Expression left = ((EqualTo) wildWhere).left();
+        Expression right = ((EqualTo) wildWhere).right();
+        if (!(left instanceof UnboundSlot && ((UnboundSlot) 
left).getName().equalsIgnoreCase("jobName"))) {
+            throw new AnalysisException("Current not support left child of 
where: " + left);
+        }
+        if (!(right instanceof StringLikeLiteral)) {
+            throw new AnalysisException("Value must is string");
+        }
+
+        if (Strings.isNullOrEmpty(((StringLikeLiteral) 
right).getStringValue())) {
+            throw new AnalysisException("Value can't is null");
+        }
+        this.jobName = ((StringLikeLiteral) right).getStringValue();
+        if (jobName.startsWith(excludeJobNamePrefix)) {
+            throw new AnalysisException("Can't alter inner job status");
+        }
+    }
+
+    public abstract void doRun(ConnectContext ctx, StmtExecutor executor) 
throws Exception;
+
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CancelJobTaskCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CancelJobTaskCommand.java
new file mode 100644
index 00000000000..a9ea241e3b6
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CancelJobTaskCommand.java
@@ -0,0 +1,99 @@
+// 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.
+
+package org.apache.doris.nereids.trees.plans.commands;
+
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.common.ErrorCode;
+import org.apache.doris.common.ErrorReport;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+import org.apache.doris.nereids.analyzer.UnboundSlot;
+import org.apache.doris.nereids.trees.expressions.And;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.literal.LargeIntLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.StringLikeLiteral;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.StmtExecutor;
+
+/**
+ * base class for all drop commands
+ */
+public class CancelJobTaskCommand extends Command implements ForwardWithSync {
+    private static final String jobNameKey = "jobName";
+
+    private static final String taskIdKey = "taskId";
+
+    private String jobName;
+
+    private Long taskId;
+
+    private Expression expr;
+
+    public CancelJobTaskCommand(Expression expr) {
+        super(PlanType.CANCEL_JOB_COMMAND);
+        this.expr = expr;
+    }
+
+    @Override
+    public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
+        return visitor.visitCancelTaskCommand(this, context);
+    }
+
+    @Override
+    public void run(ConnectContext ctx, StmtExecutor executor) throws 
Exception {
+        validate();
+        doRun(ctx);
+    }
+
+    private void validate() throws AnalysisException {
+        if 
(!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), 
PrivPredicate.ADMIN)) {
+            
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, 
"ADMIN");
+        }
+        if (!(expr instanceof And)) {
+            throw new AnalysisException("Only allow compound predicate with 
operator AND");
+        }
+        if (!(expr.child(0).child(0) instanceof UnboundSlot)
+                && jobNameKey.equals(((UnboundSlot) 
expr.child(0).child(0)).getName())) {
+            throw new AnalysisException("Current not support " + 
((UnboundSlot) expr.child(0).child(0)).getName());
+        }
+
+        if (!(expr.child(0).child(1) instanceof StringLikeLiteral)) {
+            throw new AnalysisException("JobName value must is string");
+        }
+        this.jobName = ((StringLikeLiteral) 
expr.child(0).child(1)).getStringValue();
+        String taskIdInput = ((StringLikeLiteral) 
expr.child(1).child(0)).getStringValue();
+        if (!taskIdKey.equalsIgnoreCase(taskIdInput)) {
+            throw new AnalysisException("Current not support " + taskIdInput);
+        }
+        if (!(expr.child(1).child(1) instanceof LargeIntLiteral)) {
+            throw new AnalysisException("task id  value must is large int");
+        }
+        this.taskId = ((LargeIntLiteral) 
expr.child(1).child(1)).getLongValue();
+    }
+
+    public void doRun(ConnectContext ctx) throws Exception {
+        try {
+            ctx.getEnv().getJobManager().cancelTaskById(jobName, taskId);
+        } catch (Exception e) {
+            throw new DdlException(e.getMessage());
+        }
+    }
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DropJobCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DropJobCommand.java
new file mode 100644
index 00000000000..69c00a0b084
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DropJobCommand.java
@@ -0,0 +1,51 @@
+// 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.
+
+package org.apache.doris.nereids.trees.plans.commands;
+
+import org.apache.doris.analysis.StmtType;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.StmtExecutor;
+
+/**
+ * base class for all drop commands
+ */
+public class DropJobCommand extends AlterJobStatusCommand implements 
ForwardWithSync {
+    private final boolean ifExists;
+
+    public DropJobCommand(Expression wildWhere, boolean ifExists) {
+        super(PlanType.DROP_JOB_COMMAND, wildWhere);
+        this.ifExists = ifExists;
+    }
+
+    @Override
+    public StmtType stmtType() {
+        return StmtType.DROP;
+    }
+
+    @Override
+    public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
+        return visitor.visitDropJobCommand(this, context);
+    }
+
+    public void doRun(ConnectContext ctx, StmtExecutor executor) throws 
Exception {
+        ctx.getEnv().getJobManager().unregisterJob(super.getJobName(), 
ifExists);
+    }
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/PauseJobCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/PauseJobCommand.java
new file mode 100644
index 00000000000..2954c79b074
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/PauseJobCommand.java
@@ -0,0 +1,50 @@
+// 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.
+
+package org.apache.doris.nereids.trees.plans.commands;
+
+import org.apache.doris.analysis.StmtType;
+import org.apache.doris.job.common.JobStatus;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.StmtExecutor;
+
+/**
+ * pause job
+ */
+public class PauseJobCommand extends AlterJobStatusCommand implements 
ForwardWithSync {
+    public PauseJobCommand(Expression wildWhere) {
+        super(PlanType.PAUSE_JOB_COMMAND, wildWhere);
+    }
+
+    @Override
+    public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
+        return visitor.visitPauseJobCommand(this, context);
+    }
+
+    @Override
+    public void doRun(ConnectContext ctx, StmtExecutor executor) throws 
Exception {
+        ctx.getEnv().getJobManager().alterJobStatus(super.getJobName(), 
JobStatus.PAUSED);
+    }
+
+    @Override
+    public StmtType stmtType() {
+        return StmtType.PAUSE;
+    }
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ResumeJobCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ResumeJobCommand.java
new file mode 100644
index 00000000000..88ee9fe0774
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ResumeJobCommand.java
@@ -0,0 +1,50 @@
+// 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.
+
+package org.apache.doris.nereids.trees.plans.commands;
+
+import org.apache.doris.analysis.StmtType;
+import org.apache.doris.job.common.JobStatus;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.plans.PlanType;
+import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.StmtExecutor;
+
+/**
+ * pause job
+ */
+public class ResumeJobCommand extends AlterJobStatusCommand implements 
ForwardWithSync {
+    public ResumeJobCommand(Expression wildWhere) {
+        super(PlanType.RESUME_JOB_COMMAND, wildWhere);
+    }
+
+    @Override
+    public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
+        return visitor.visitResumeJobCommand(this, context);
+    }
+
+    @Override
+    public void doRun(ConnectContext ctx, StmtExecutor executor) throws 
Exception {
+        ctx.getEnv().getJobManager().alterJobStatus(super.getJobName(), 
JobStatus.RUNNING);
+    }
+
+    @Override
+    public StmtType stmtType() {
+        return StmtType.PAUSE;
+    }
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/CommandVisitor.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/CommandVisitor.java
index 9bffb5a376e..8e08f75aebb 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/CommandVisitor.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/CommandVisitor.java
@@ -18,10 +18,12 @@
 package org.apache.doris.nereids.trees.plans.visitor;
 
 import org.apache.doris.nereids.trees.plans.commands.AddConstraintCommand;
+import org.apache.doris.nereids.trees.plans.commands.AlterJobStatusCommand;
 import org.apache.doris.nereids.trees.plans.commands.AlterMTMVCommand;
 import org.apache.doris.nereids.trees.plans.commands.AlterRoleCommand;
 import org.apache.doris.nereids.trees.plans.commands.AlterViewCommand;
 import org.apache.doris.nereids.trees.plans.commands.CallCommand;
+import org.apache.doris.nereids.trees.plans.commands.CancelJobTaskCommand;
 import org.apache.doris.nereids.trees.plans.commands.CancelMTMVTaskCommand;
 import org.apache.doris.nereids.trees.plans.commands.Command;
 import org.apache.doris.nereids.trees.plans.commands.CreateJobCommand;
@@ -35,6 +37,7 @@ import 
org.apache.doris.nereids.trees.plans.commands.DeleteFromCommand;
 import org.apache.doris.nereids.trees.plans.commands.DeleteFromUsingCommand;
 import 
org.apache.doris.nereids.trees.plans.commands.DropCatalogRecycleBinCommand;
 import org.apache.doris.nereids.trees.plans.commands.DropConstraintCommand;
+import org.apache.doris.nereids.trees.plans.commands.DropJobCommand;
 import org.apache.doris.nereids.trees.plans.commands.DropMTMVCommand;
 import org.apache.doris.nereids.trees.plans.commands.DropProcedureCommand;
 import org.apache.doris.nereids.trees.plans.commands.DropRoleCommand;
@@ -42,12 +45,14 @@ import 
org.apache.doris.nereids.trees.plans.commands.DropSqlBlockRuleCommand;
 import org.apache.doris.nereids.trees.plans.commands.ExplainCommand;
 import org.apache.doris.nereids.trees.plans.commands.ExportCommand;
 import org.apache.doris.nereids.trees.plans.commands.LoadCommand;
+import org.apache.doris.nereids.trees.plans.commands.PauseJobCommand;
 import org.apache.doris.nereids.trees.plans.commands.PauseMTMVCommand;
 import org.apache.doris.nereids.trees.plans.commands.RecoverDatabaseCommand;
 import org.apache.doris.nereids.trees.plans.commands.RecoverPartitionCommand;
 import org.apache.doris.nereids.trees.plans.commands.RecoverTableCommand;
 import org.apache.doris.nereids.trees.plans.commands.RefreshMTMVCommand;
 import org.apache.doris.nereids.trees.plans.commands.ReplayCommand;
+import org.apache.doris.nereids.trees.plans.commands.ResumeJobCommand;
 import org.apache.doris.nereids.trees.plans.commands.ResumeMTMVCommand;
 import 
org.apache.doris.nereids.trees.plans.commands.SetDefaultStorageVaultCommand;
 import org.apache.doris.nereids.trees.plans.commands.SetOptionsCommand;
@@ -164,6 +169,10 @@ public interface CommandVisitor<R, C> {
         return visitCommand(dropConstraintCommand, context);
     }
 
+    default R visitDropJobCommand(DropJobCommand dropJobCommand, C context) {
+        return visitCommand(dropJobCommand, context);
+    }
+
     default R visitShowConstraintsCommand(ShowConstraintsCommand 
showConstraintsCommand, C context) {
         return visitCommand(showConstraintsCommand, context);
     }
@@ -176,10 +185,18 @@ public interface CommandVisitor<R, C> {
         return visitCommand(dropMTMVCommand, context);
     }
 
+    default R visitPauseJobCommand(PauseJobCommand pauseJobCommand, C context) 
{
+        return visitCommand(pauseJobCommand, context);
+    }
+
     default R visitPauseMTMVCommand(PauseMTMVCommand pauseMTMVCommand, C 
context) {
         return visitCommand(pauseMTMVCommand, context);
     }
 
+    default R visitResumeJobCommand(ResumeJobCommand resumeJobCommand, C 
context) {
+        return visitCommand(resumeJobCommand, context);
+    }
+
     default R visitResumeMTMVCommand(ResumeMTMVCommand resumeMTMVCommand, C 
context) {
         return visitCommand(resumeMTMVCommand, context);
     }
@@ -192,6 +209,10 @@ public interface CommandVisitor<R, C> {
         return visitCommand(cancelMTMVTaskCommand, context);
     }
 
+    default R visitCancelTaskCommand(CancelJobTaskCommand 
cancelJobTaskCommand, C context) {
+        return visitCommand(cancelJobTaskCommand, context);
+    }
+
     default R visitCallCommand(CallCommand callCommand, C context) {
         return visitCommand(callCommand, context);
     }
@@ -216,6 +237,10 @@ public interface CommandVisitor<R, C> {
         return visitCommand(createViewCommand, context);
     }
 
+    default R visitAlterJobStatusCommand(AlterJobStatusCommand 
alterJobStatusCommand, C context) {
+        return visitCommand(alterJobStatusCommand, context);
+    }
+
     default R visitAlterViewCommand(AlterViewCommand alterViewCommand, C 
context) {
         return visitCommand(alterViewCommand, context);
     }


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

Reply via email to