zabetak commented on code in PR #4525:
URL: https://github.com/apache/calcite/pull/4525#discussion_r2333286329


##########
core/src/main/java/org/apache/calcite/rex/RexSimplify.java:
##########
@@ -3128,10 +3130,17 @@ private boolean accept2b(RexNode e, SqlKind kind,
       case EQUALS:
         b.addRange(Range.singleton(value), literal.getType());
         return true;
+      case IS_NOT_DISTINCT_FROM:
+        b.addRange(Range.singleton(value), literal.getType(), FALSE);
+        return true;
       case NOT_EQUALS:
         b.addRange(Range.lessThan(value), literal.getType());
         b.addRange(Range.greaterThan(value), literal.getType());
         return true;
+      case IS_DISTINCT_FROM:
+        b.addRange(Range.lessThan(value), literal.getType(), TRUE);

Review Comment:
   It should work for all types that are comparable. `IS_DISTICT_FROM` like 
`NOT_EQUALS` are comparison operators so it doesn't make sense to use them for 
non-comparable types. Trying to use `IS_DISTINCT_FROM` on a non-comparable type 
should raise an error during the creation of the call so we wouldn't even reach 
the simplifier.
   
   From the moment that we do this simplification (unconditionally) for all 
other comparison operators I would say that doing it also for `DISTINCT` 
predicates is always an improvement.



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to