Skip to content

Commit

Permalink
fix partition prune
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Nov 26, 2024
1 parent 1e2edbc commit e811e76
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,19 @@ public Expression visit(Expression originExpr, Context parentContext) {
public Expression visitAnd(And and, Context parentContext) {
List<Expression> children = and.children();
List<Expression> newChildren = Lists.newArrayListWithCapacity(children.size());
boolean hasNewChild = false;
boolean changed = false;
for (Expression child : children) {
Context childContext = new Context();
Expression newChild = child.accept(this, childContext);
hasNewChild |= !newChild.equals(child);
// if anyone of them is FALSE, the whole expression should be FALSE.
if (newChild == BooleanLiteral.FALSE) {
return BooleanLiteral.FALSE;
}
if (newChild != BooleanLiteral.TRUE && !childContext.containsUnEvaluableExpression) {
newChildren.add(newChild);
changed |= !newChild.equals(child);
} else {
changed = true;
}
}
if (newChildren.isEmpty()) {
Expand All @@ -124,8 +126,12 @@ public Expression visitAnd(And and, Context parentContext) {
if (newChildren.size() == 1) {
return newChildren.get(0);
}
if (hasNewChild) {
return and.withChildren(newChildren);
if (changed) {
if (newChildren.isEmpty()) {
return BooleanLiteral.TRUE;
} else {
return and.withChildren(newChildren);
}
} else {
return and;
}
Expand Down

0 comments on commit e811e76

Please sign in to comment.