Skip to content

Commit

Permalink
fix fold-const/cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Nov 29, 2024
1 parent 4f76666 commit 97bd558
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.apache.doris.load.loadv2.JobState;
import org.apache.doris.mysql.privilege.PrivPredicate;
import org.apache.doris.nereids.trees.expressions.And;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.qe.ConnectContext;

import com.google.common.collect.Lists;
Expand Down Expand Up @@ -528,7 +529,7 @@ private static void addNeedCancelLoadJob(String label, String state,
* used for nereids planner
*/
public void cancelLoadJob(String dbName, String label, String state,
org.apache.doris.nereids.trees.expressions.CompoundPredicate operator)
Expression operator)
throws JobException, AnalysisException, DdlException {
Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(dbName);
// List of load jobs waiting to be cancelled
Expand Down Expand Up @@ -582,7 +583,7 @@ public void cancelLoadJob(String dbName, String label, String state,
}

private static void addNeedCancelLoadJob(String label, String state,
org.apache.doris.nereids.trees.expressions.CompoundPredicate operator,
Expression operator,
List<InsertJob> loadJobs,
List<InsertJob> matchLoadJobs)
throws AnalysisException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import org.apache.doris.load.Load;
import org.apache.doris.mysql.privilege.PrivPredicate;
import org.apache.doris.nereids.trees.expressions.And;
import org.apache.doris.nereids.trees.expressions.CompoundPredicate;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.persist.CleanLabelOperationLog;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.OriginStatement;
Expand Down Expand Up @@ -248,7 +248,7 @@ public void recordFinishedLoadJob(String label, long transactionId, String dbNam
* Match need cancel loadJob by stmt.
**/
@VisibleForTesting
public static void addNeedCancelLoadJob(String label, String state, CompoundPredicate operator,
public static void addNeedCancelLoadJob(String label, String state, Expression operator,
List<LoadJob> loadJobs, List<LoadJob> matchLoadJobs)
throws AnalysisException {
PatternMatcher matcher = PatternMatcherWrapper.createMysqlPattern(label,
Expand Down Expand Up @@ -281,7 +281,7 @@ public static void addNeedCancelLoadJob(String label, String state, CompoundPred
/**
* Cancel load job by stmt.
**/
public void cancelLoadJob(String dbName, String label, String state, CompoundPredicate operator)
public void cancelLoadJob(String dbName, String label, String state, Expression operator)
throws DdlException, AnalysisException {
Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(dbName);
// List of load jobs waiting to be cancelled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,11 @@ public Expression visitAnd(And and, ExpressionRewriteContext context) {
// x and y
return and.withChildren(nonTrueLiteral);
}
} else if (nullCount == 1) {
if (nonTrueLiteral.size() == 1) {
// null and true
return new NullLiteral(BooleanType.INSTANCE);
}
} else if (nullCount < and.children().size()) {
// null and x
return and.withChildren(nonTrueLiteral);
} else {
// null and null
// null and null and null and ...
return new NullLiteral(BooleanType.INSTANCE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,18 @@ private void binaryCheck(Expression expr, Map<String, String> supportedColumns)
private void compoundCheck(Expression expr, Map<String, String> supportedColumns) throws AnalysisException {
// current only support label and state
if (expr instanceof Not) {
throw new AnalysisException("Current not support NOT operator");
throw new AnalysisException("not support NOT operator");
}
for (int i = 0; i < 2; i++) {
Expression child = expr.child(i);
if (child instanceof CompoundPredicate) {
throw new AnalysisException("Current not support nested clause");
throw new AnalysisException("not support where clause: " + expr.toSql());
} else if (child instanceof Like) {
likeCheck(child, supportedColumns);
} else if (child instanceof BinaryOperator) {
binaryCheck(child, supportedColumns);
} else {
throw new AnalysisException("Only support like/binary predicate");
throw new AnalysisException("Only support like/equalTo/And/Or predicate");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.doris.common.UserException;
import org.apache.doris.job.exception.JobException;
import org.apache.doris.load.ExportJobState;
import org.apache.doris.nereids.trees.expressions.CompoundPredicate;
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;
Expand Down Expand Up @@ -57,9 +56,9 @@ public CancelLoadCommand(String dbName, Expression whereClause) {
public void run(ConnectContext ctx, StmtExecutor executor) throws Exception {
validate(ctx);
try {
ctx.getEnv().getJobManager().cancelLoadJob(dbName, label, state, (CompoundPredicate) whereClause);
ctx.getEnv().getJobManager().cancelLoadJob(dbName, label, state, whereClause);
} catch (JobException e) {
ctx.getEnv().getLoadManager().cancelLoadJob(dbName, label, state, (CompoundPredicate) whereClause);
ctx.getEnv().getLoadManager().cancelLoadJob(dbName, label, state, whereClause);
}
}

Expand Down

0 comments on commit 97bd558

Please sign in to comment.