DonnyZone commented on a change in pull request #1592: [CALCITE-3512] Query
fails when comparing Time/TimeStamp types
URL: https://github.com/apache/calcite/pull/1592#discussion_r348963145
##########
File path:
core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
##########
@@ -1061,10 +1061,22 @@ public static Expression convert(Expression operand,
Type fromType,
Expressions.convert_(operand, toBox.primitiveClass),
toBox);
} else if (fromType == java.sql.Date.class) {
- if (toBox == Primitive.INT) {
+ if (toType == int.class) {
Review comment:
It is a little different. To some extent,
`RexToLixTranslator.convert(Expression operand, Type fromType, Type toType)` is
more general.
In `RexToLixTranslator.convert(Expression operand, Type fromType, Type
toType)`, the `fromType` is not always the same as `operand.getType()`. Because
in current codegen, there are some places (e.g., the row input) need to use
`Object.class` as common type.
For example, the sample code below:
```
Object[] input = ...
//convert(input[0], Timestamp.class, long.class)
long x = SqlFunctions.toLong(input[0]);
```
Therefore, `EnumUtils.enforce` function cannot meet the requirement. This is
also the reason why we have `toInt(Object ..)`/`toLong(Object ..)` in
`SqlFunctions`.
It is introduced in
[CALCITE-1569]((https://issues.apache.org/jira/browse/CALCITE-1569)
----------------------------------------------------------------
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