rubenada commented on a change in pull request #1322: [CALCITE-3198]
ReduceExpressionsRule.FILTER_INSTANCE does not reduce 'NOT(x=a AND x=b)'
URL: https://github.com/apache/calcite/pull/1322#discussion_r307613850
##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -1624,6 +1626,24 @@ private RexNode simplifyOrs(List<RexNode> terms,
RexUnknownAs unknownAs) {
continue;
}
}
+ break;
+ case NOT_EQUALS:
+ Comparison notEqualsComparison =
+ Comparison.of(term, node -> RexUtil.isReferenceOrAccess(node,
false));
+ if (notEqualsComparison != null) {
+ Comparison prevNotEqualsComparison =
notEqualsComparisonMap.get(notEqualsComparison.ref);
+ if (prevNotEqualsComparison == null) {
+ notEqualsComparisonMap.put(notEqualsComparison.ref,
notEqualsComparison);
+ } else {
+ Comparable comparable1 = notEqualsComparison.literal.getValue();
+ Comparable comparable2 =
prevNotEqualsComparison.literal.getValue();
+ //noinspection unchecked
+ if (comparable1.compareTo(comparable2) != 0) {
+ return rexBuilder.makeLiteral(true);
Review comment:
@kgyrtkirk when you have some time, please check the latest status of the
PR, which should handle the nullability scenario that you mentioned.
----------------------------------------------------------------
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]
With regards,
Apache Git Services