danny0405 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_r349903200
##########
File path:
core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java
##########
@@ -1060,38 +1117,26 @@ public static Expression convert(Expression operand,
Type fromType,
return Expressions.box(
Expressions.convert_(operand, toBox.primitiveClass),
toBox);
- } else if (fromType == java.sql.Date.class) {
- if (toBox == Primitive.INT) {
- return Expressions.call(BuiltInMethod.DATE_TO_INT.method, operand);
- } else {
- return Expressions.convert_(operand, toType);
- }
- } else if (toType == java.sql.Date.class) {
- // E.g. from "int" or "Integer" to "java.sql.Date",
- // generate "SqlFunctions.internalToDate".
- if (isA(fromType, Primitive.INT)) {
- return Expressions.call(BuiltInMethod.INTERNAL_TO_DATE.method,
operand);
- } else {
- return Expressions.convert_(operand, java.sql.Date.class);
- }
- } else if (toType == java.sql.Time.class) {
- // E.g. from "int" or "Integer" to "java.sql.Time",
- // generate "SqlFunctions.internalToTime".
- if (isA(fromType, Primitive.INT)) {
- return Expressions.call(BuiltInMethod.INTERNAL_TO_TIME.method,
operand);
- } else {
- return Expressions.convert_(operand, java.sql.Time.class);
+ }
+ // Convert from 'java.sql.Date/java.sql.Time/java.sql.Timestamp'
+ // to internal storage types ('int/Integer/long/Long')
+ if (representAsInternalType(fromType)) {
Review comment:
```java
// Convert datetime types to internal storage type:
// 1. java.sql.Date -> int or Integer
// 2. java.sql.Time -> int or Integer
// 3. java.sql.Timestamp -> long or Long
```
----------------------------------------------------------------
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