Skip to content

Commit

Permalink
[bugfix](nereids) prune partition bug in pattern ColA <> ColB #25769 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly authored Nov 1, 2023
1 parent a35de81 commit 81b5f74
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.doris.nereids.CascadesContext;
import org.apache.doris.nereids.rules.expression.ExpressionRewriteContext;
import org.apache.doris.nereids.rules.expression.rules.TryEliminateUninterestedPredicates.Context;
import org.apache.doris.nereids.trees.expressions.And;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.expressions.literal.BooleanLiteral;
Expand Down Expand Up @@ -104,6 +105,27 @@ public Expression visit(Expression originExpr, Context parentContext) {
return expr;
}

@Override
public Expression visitAnd(And and, Context parentContext) {
Expression left = and.left();
Context leftContext = new Context();
Expression newLeft = this.visit(left, leftContext);
if (leftContext.childrenContainsNonInterestedSlots) {
newLeft = BooleanLiteral.TRUE;
}

Expression right = and.right();
Context rightContext = new Context();
Expression newRight = this.visit(right, rightContext);
if (rightContext.childrenContainsNonInterestedSlots) {
newRight = BooleanLiteral.TRUE;
}
Expression expr = new And(newLeft, newRight).accept(FoldConstantRuleOnFE.INSTANCE, expressionRewriteContext);
parentContext.childrenContainsInterestedSlots =
rightContext.childrenContainsInterestedSlots || leftContext.childrenContainsInterestedSlots;
return expr;
}

@Override
public Expression visitSlot(Slot slot, Context context) {
boolean isInterestedSlot = interestedSlots.contains(slot);
Expand Down

0 comments on commit 81b5f74

Please sign in to comment.