Anthrino commented on code in PR #3677:
URL: https://github.com/apache/calcite/pull/3677#discussion_r1498158155
##########
core/src/main/java/org/apache/calcite/adapter/enumerable/RexToLixTranslator.java:
##########
@@ -647,58 +541,225 @@ private static Expression checkExpressionPadTruncate(
}
}
+ private Expression translateCastToDate(RelDataType sourceType,
+ Expression operand, ConstantExpression format,
+ Supplier<Expression> defaultExpression) {
+
+ switch (sourceType.getSqlTypeName()) {
+ case CHAR:
+ case VARCHAR:
+ // If format string is supplied, parse formatted string into date
+ return Expressions.isConstantNull(format)
+ ? Expressions.call(BuiltInMethod.STRING_TO_DATE.method, operand)
+ :
Expressions.call(Expressions.new_(BuiltInMethod.PARSE_DATE.method.getDeclaringClass()),
Review Comment:
The declaring functions are from `SqlFunctions` but might belong to
subclasses, e.g.
```
FORMAT_DATE => SqlFunctions.DateFormatFunction.class
PARSE_TIME => SqlFunctions.DateParseFunction.class
```
my assumption is we need to pass the inner class name as the
`targetExpression`, I am not completely aware of the use of this
[`targetExpression`](https://github.com/apache/calcite/blob/7ca6fc4bdd3e1274a62f00f4c8d5830162a74879/linq4j/src/main/java/org/apache/calcite/linq4j/tree/MethodCallExpression.java#L33)
attribute in the `MethodCallExpression` class, if anyone else can confirm?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]