rubenada commented on a change in pull request #2253:
URL: https://github.com/apache/calcite/pull/2253#discussion_r522040936
##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -1689,6 +1690,123 @@ RexNode simplifyAnd2ForUnknownAsFalse(List<RexNode>
terms,
}
}
+ /**
+ * <p>Simplifies AND/OR condition that has common expressions,
+ * extract and eliminate/merge them as much as possible.</p>
+ * <ul>
+ * <li>(a OR b) AND (a OR b OR c OR d) => (a OR b)
+ * <li>(a OR b OR c OR d) AND (a OR b OR e OR f) => (a OR b) OR ((c OR d)
AND (e OR f))
+
+ * <li>(a AND b) OR (a AND b AND c) => (a AND b)
+ * <li>(a AND b AND c AND d) OR (a AND b AND e AND f) =>
+ * (a AND b) AND ((c AND d) OR (e AND f))
+ * </ul>
+ * <p> The difference between {@link #simplifyAnd} is that {@link
#simplifyAnd} mainly
+ * simplifies expressions whose answer can be determined without evaluating
both sides,
+ * like: FALSE AND (xxx) => FALSE</p>
+ */
+ public RexNode eliminateCommonExprInCondition(RexNode call) {
Review comment:
I uderstand @Aaaaaaron , thanks for the explanation.
IMHO the current PR as it is (a new method that is not used, apart from the
unit test), does not make much sense. I would prefer to see a PR combining 1 &
2 from my previous comment (i.e. this new method, used by a certain join rule,
so that we can see it "in action").
Having said that, if people think otherwise, I would not oppose to merging
the current PR as it is.
----------------------------------------------------------------
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]