In the AbstractTypeCoercion class, I see here
<https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java#L675>,
that DateTime family contains types SqlTypeFamily.DATE, SqlTypeFamily.TIME,
SqlTypeFamily.TIMESTAMP. Here
<https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java#L709>
I
can see that the Char types can be cast to DateTime type.

However, if I define a SqlFunction with an operand of
SqlTypeFamily.DATETIME type then this logic fails and implicit cast does
not work.

As far as I understand SqlTypeFamily.DATETIME contains SqlTypeName of DATE,
TIME, TIME_WITH_LOCAL_TIME_ZONE, TIMESTAMP, TIMESTAMP_WITH_LOCAL_TIME_ZONE.
So shouldn't implicit cast work from Char to DATETIME work as well.

Couple questions -
1. Is the DATETIME here used to represent values in 'YYYY-MM-DD hh:mm:ss'
format or is it just a family type ?
2. What operand type should be used to define a function which can accept
DATE and TIMESTAMP as well as values in 'YYYY-MM-DD hh:mm:ss'  format ?

Thanks

Reply via email to