Aaaaaaron commented on a change in pull request #2253:
URL: https://github.com/apache/calcite/pull/2253#discussion_r535081748



##########
File path: core/src/test/java/org/apache/calcite/rex/RexProgramTest.java
##########
@@ -3159,4 +3160,44 @@ private SqlSpecialOperatorWithPolicy(String name, 
SqlKind kind, int prec, boolea
   @Test void testSimplifyVarbinary() {
     checkSimplifyUnchanged(cast(cast(vInt(), tVarchar(true, 100)), 
tVarbinary(true)));
   }
+
+  @Test public void testEliminateCommonExprInCondition() {
+    RexSimplify rexSimplify = new RexSimplify(rexBuilder, 
RelOptPredicateList.EMPTY, EXECUTOR);
+
+    // (a=b && c=7) || (a=b && c=7 && d=8) => (a=b && c=7)
+    RexNode or1 = or(
+        and(vBool(0), vBool(1)),
+        and(vBool(0), vBool(1), vBool(2))
+    );
+    RexNode orSimplified2 = rexSimplify.eliminateCommonExprInCondition(or1);

Review comment:
       😂 Revised.

##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -1698,6 +1699,113 @@ RexNode simplifyAnd2ForUnknownAsFalse(List<RexNode> 
terms,
     }
   }
 
+  /**
+   * <p>Simplifies AND/OR condition that has common expressions,
+   * extract and eliminate/merge them as much as possible.</p>

Review comment:
       Revised




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to