DonnyZone commented on a change in pull request #1609: [CALCITE-3520] Type cast 
from primitive to box is not correct
URL: https://github.com/apache/calcite/pull/1609#discussion_r351570756
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumUtils.java
 ##########
 @@ -394,16 +392,6 @@ public static Expression convert(Expression operand, Type 
fromType,
               Expressions.unbox(operand, toBox),
               toBox));
     } else if (fromPrimitive != null && toBox != null) {
-      // E.g. from "int" to "Long".
-      // Generate Long.valueOf(x)
-      // Eliminate primitive casts like Long.valueOf((long) x)
-      if (operand instanceof UnaryExpression) {
-        UnaryExpression una = (UnaryExpression) operand;
-        if (una.nodeType == ExpressionType.Convert
-            || Primitive.of(una.getType()) == toBox) {
-          return Expressions.box(una.expression, toBox);
-        }
-      }
 
 Review comment:
   Yes, this line of code for general case is also added by me in [CALCITE-3414 
](https://github.com/apache/calcite/pull/1507).
   But the optimization targets on the pattern like
   `(byte)(int)->Byte`
   In which the operand is `UnaryExpression` with `ExpressionType.Convert`

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