kgyrtkirk commented on a change in pull request #1044: [CALCITE-2838] 
Simplification: Remove redundant IS TRUE/IS NOT FALSE …
URL: https://github.com/apache/calcite/pull/1044#discussion_r256860106
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/rex/RexSimplify.java
 ##########
 @@ -494,10 +494,16 @@ private RexNode simplifyNot(RexCall call, RexUnknownAs 
unknownAs) {
     return call;
   }
 
-  private RexNode simplifyIs(RexCall call) {
+  private RexNode simplifyIs(RexCall call, RexUnknownAs unknownAs) {
     final SqlKind kind = call.getKind();
-    final RexNode a = call.getOperands().get(0);
-
+    final RexNode argument = call.getOperands().get(0);
+    if (kind == SqlKind.IS_TRUE && unknownAs == RexUnknownAs.FALSE) {
+      return simplify(argument, unknownAs);
+    }
+    if (kind == SqlKind.IS_NOT_FALSE && unknownAs == RexUnknownAs.TRUE) {
+      return simplify(argument, unknownAs);
+    }
+    final RexNode a = simplify(call.getOperands().get(0), 
RexUnknownAs.UNKNOWN);
 
 Review comment:
   I think this shouldn't be `N^2` ; because it actually drops the "IS X" part 
and continues with the recursion on the argument.
   I've deliberitely placed the existing `simplify` call after the checks of 
redundancy.
   
   Thank you for taking a look!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Reply via email to