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 dd17183
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,11 @@ void register(MutableRel result, MutableRel query) {
RexNode condition, RexNode target) {
final RexBuilder rexBuilder = simplify.rexBuilder;
condition = simplify.simplify(condition);
target = simplify.simplify(target);
RexNode condition2 = canonizeNode(rexBuilder, condition);
if (target.isAlwaysTrue()) {
return condition2;
}
target = simplify.simplify(target);
RexNode target2 = canonizeNode(rexBuilder, target);

// First, try splitting into ORs.
Expand All @@ -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 dd17183

Please sign in to comment.