You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/11/28 02:35:26 UTC

[GitHub] [calcite] DonnyZone commented on a change in pull request #1609: [CALCITE-3520] Type cast from primitive to box is not correct

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:
users@infra.apache.org


With regards,
Apache Git Services