tanclary commented on code in PR #3248:
URL: https://github.com/apache/calcite/pull/3248#discussion_r1223585800
##########
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##########
@@ -302,6 +302,29 @@ public static SqlCall stripSeparator(SqlCall call) {
public static final SqlReturnTypeInference DATE_NULLABLE =
DATE.andThen(SqlTypeTransforms.TO_NULLABLE);
+ /**
+ * Type-inference strategy that returns the type of the first operand,
+ * unless it is a DATE, in which case the return type is TIMESTAMP.
+ */
+ public static final SqlReturnTypeInference ARG0_EXCEPT_DATE = opBinding -> {
Review Comment:
Updated, let me know if it's clear enough
##########
core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java:
##########
@@ -2049,6 +2054,21 @@ private static class TimestampAddConvertlet implements
SqlRexConvertlet {
}
}
+ /** Convertlet that handles the BigQuery {@code DATETIME_TRUNC} and
+ * {@code TIMESTAMP_TRUNC} functions. */
+ private static class TruncConvertlet implements SqlRexConvertlet {
+ @Override public RexNode convertCall(SqlRexContext cx, SqlCall call) {
+ final RexBuilder rexBuilder = cx.getRexBuilder();
+ RexNode op1 = cx.convertExpression(call.operand(0));
+ RexNode op2 = cx.convertExpression(call.operand(1));
+ if (op1.getType().getSqlTypeName() == SqlTypeName.DATE) {
Review Comment:
Same as above
--
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]