Hi all,
I am implementing a STR_TO_DATE scalar SQL function to flink, and
found return type casted from java.sql.Date to Integer in Flink’s
ExpressionReducer:
https://github.com/apache/flink/blob/master/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/ExpressionReducer.scala#L56
// we need to cast here for RexBuilder.makeLiteral
case (SqlTypeName.DATE, e) =>
Some(
rexBuilder.makeCast(typeFactory.createTypeFromTypeInfo(BasicTypeInfo.INT_TYPE_INFO),
e)
)
so str_to_date('01,5,2013','%d,%m,%Y')" must return an Integer,
which conflicted with my implementation.
My question is: why should we do this? I have seen in comments the
reason to do this here is: “we need to cast here for RexBuilder.makeLiteral”,
But is it reasonale to change user function’s return Type? Should we restore
the origin return type after the reduce?
Thanks,
Aegeaner