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_r347775534
 
 

 ##########
 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) {
         return Expressions.call(BuiltInMethod.DATE_TO_INT.method, operand);
-      } else {
-        return Expressions.convert_(operand, toType);
+      } else if (toType == Integer.class) {
+        return Expressions.call(BuiltInMethod.DATE_TO_INT_OPTIONAL.method, 
operand);
 
 Review comment:
   @danny0405 I incline to fix them.
   On one hand, `RexToLixTranslator.convert()` is a public and static 
interface. The null check policy is only guaranteed in current codegen 
framework. We cannot prevent user or developers to call it. On the other hand, 
with the evolution of codegen, more problem will exposed. For example, another 
pattern in [CALCITE-3520](https://issues.apache.org/jira/browse/CALCITE-3520). 
I add a new test file for these underlying issues. 

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