jcamachor commented on a change in pull request #1909: [CALCITE-3914] Improve 
SubsitutionVisitor to consider RexCall of type PLUS and TIMES for 
canonicalization (Vineet Garg)
URL: https://github.com/apache/calcite/pull/1909#discussion_r406995687
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
 ##########
 @@ -345,13 +345,29 @@ private static RexNode canonizeNode(RexBuilder 
rexBuilder, RexNode condition) {
     case LESS_THAN_OR_EQUAL:
     case GREATER_THAN_OR_EQUAL: {
       RexCall call = (RexCall) condition;
-      final RexNode left = call.getOperands().get(0);
-      final RexNode right = call.getOperands().get(1);
+      RexNode left = call.getOperands().get(0);
+      left = canonizeNode(rexBuilder, left);
+      RexNode right = call.getOperands().get(1);
+      right = canonizeNode(rexBuilder, right);
+      call = (RexCall) rexBuilder.makeCall(call.getOperator(), left, right);
       if (left.toString().compareTo(right.toString()) <= 0) {
         return call;
 
 Review comment:
   You can only return the original call if `left==call.getOperands().get(0) && 
right==call.getOperands().get(1)`. Below (for + and *), you could check if that 
is the case too, and return the original call otherwise; it is worth skipping 
new expression creation in these cases).

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

Reply via email to