-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix](Nereids) fix cancel task jobs failed #44755
base: master
Are you sure you want to change the base?
Changes from 2 commits
2816bc2
5feed09
1941723
1f92321
c32dabf
c7a7652
6022e5c
4b79d8a
e33f31c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -772,39 +772,25 @@ public LogicalPlan visitCreateScheduledJob(DorisParser.CreateScheduledJobContext | |
|
||
@Override | ||
public LogicalPlan visitPauseJob(DorisParser.PauseJobContext ctx) { | ||
Expression wildWhere = null; | ||
if (ctx.wildWhere() != null) { | ||
wildWhere = getWildWhere(ctx.wildWhere()); | ||
} | ||
return new PauseJobCommand(wildWhere); | ||
return new PauseJobCommand(stripQuotes(ctx.jobNameValue.getText())); | ||
} | ||
|
||
@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); | ||
return new DropJobCommand(stripQuotes(ctx.jobNameValue.getText()), ifExists); | ||
} | ||
|
||
@Override | ||
public LogicalPlan visitResumeJob(DorisParser.ResumeJobContext ctx) { | ||
Expression wildWhere = null; | ||
if (ctx.wildWhere() != null) { | ||
wildWhere = getWildWhere(ctx.wildWhere()); | ||
} | ||
return new ResumeJobCommand(wildWhere); | ||
return new ResumeJobCommand(stripQuotes(ctx.jobNameValue.getText())); | ||
} | ||
|
||
@Override | ||
public LogicalPlan visitCancelJobTask(DorisParser.CancelJobTaskContext ctx) { | ||
Expression wildWhere = null; | ||
if (ctx.wildWhere() != null) { | ||
wildWhere = getWildWhere(ctx.wildWhere()); | ||
} | ||
return new CancelJobTaskCommand(wildWhere); | ||
String jobName = stripQuotes(ctx.jobNameValue.getText()); | ||
Long taskId = Long.valueOf(ctx.taskIdValue.getText()); | ||
Comment on lines
+802
to
+803
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what will happen if sql like |
||
return new CancelJobTaskCommand(jobName, taskId); | ||
} | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,17 +17,7 @@ | |
|
||
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; | ||
|
@@ -37,19 +27,14 @@ | |
* base class for all drop commands | ||
*/ | ||
public class CancelJobTaskCommand extends CancelCommand 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) { | ||
public CancelJobTaskCommand(String jobName, Long taskId) { | ||
super(PlanType.CANCEL_JOB_COMMAND); | ||
this.expr = expr; | ||
this.jobName = jobName; | ||
this.taskId = taskId; | ||
} | ||
|
||
@Override | ||
|
@@ -59,36 +44,9 @@ public <R, C> R accept(PlanVisitor<R, C> visitor, C context) { | |
|
||
@Override | ||
public void run(ConnectContext ctx, StmtExecutor executor) throws Exception { | ||
validate(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did we miss the permission check? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, mistoken delete |
||
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); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we do not check jobNameKey?