kgyrtkirk commented on a change in pull request #1854: [CALCITE-3852]
RexSimplify doesn't simplify NOT EQUAL predicates
URL: https://github.com/apache/calcite/pull/1854#discussion_r391428052
##########
File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
##########
@@ -1568,10 +1568,33 @@ RexNode simplifyAnd2ForUnknownAsFalse(List<RexNode>
terms,
final Comparison comparison = Comparison.of(e);
// Check for comparison with null values
if (comparison == null
- || comparison.kind == SqlKind.NOT_EQUALS
|| comparison.literal.getValue() == null) {
return e;
}
+
+ // Given x=5 and x is not null, x!=5 can be simplified to false.
+ if (comparison.kind == SqlKind.NOT_EQUALS) {
Review comment:
I think this logic could be applicable in other unknownAs modes
In case you want to do this only in UAF (this case) you may go further...and
get into nulls.
However I think that it would be better to move this out from this method
into a method which is run for all simplifyAnd-s and do it generally .
----------------------------------------------------------------
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