Skip to content

Commit

Permalink
[CALCITE-6718] Optimize SubstitutionVisitor's splitFilter with early …
Browse files Browse the repository at this point in the history
…return and uniform simplification for equivalence checking
  • Loading branch information
wangyanjing committed Dec 6, 2024
1 parent 0eb83b1 commit 18bc5f7
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ void register(MutableRel result, MutableRel query) {
@VisibleForTesting
public static @Nullable RexNode splitFilter(final RexSimplify simplify,
RexNode condition, RexNode target) {
if (target.isAlwaysTrue()) {
return condition;
}
final RexBuilder rexBuilder = simplify.rexBuilder;
condition = simplify.simplify(condition);
target = simplify.simplify(target);
Expand Down Expand Up @@ -322,7 +325,9 @@ void register(MutableRel result, MutableRel query) {
ImmutableList.of(condition2, target2));
RexNode r =
canonizeNode(rexBuilder, simplify.simplifyUnknownAsFalse(x2));
if (!r.isAlwaysFalse() && isEquivalent(condition2, r)) {
RexNode simplifiedCond2 =
canonizeNode(rexBuilder, simplify.simplifyUnknownAsFalse(condition2));
if (!r.isAlwaysFalse() && isEquivalent(simplifiedCond2, r)) {
List<RexNode> conjs = RelOptUtil.conjunctions(r);
for (RexNode e : RelOptUtil.conjunctions(target2)) {
removeAll(conjs, e);
Expand Down

0 comments on commit 18bc5f7

Please sign in to comment.