[
https://issues.apache.org/jira/browse/FLINK-14036?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16927369#comment-16927369
]
Leonard Xu commented on FLINK-14036:
------------------------------------
I got your message。
But what I am really confused is that the same expression is supported in SQL
but not supported in table api, Is it right from now?
And this part code :
TypeCoercion.canSafelyCast(new DecimalType(10,0),new DoubleType)
will throw a ValidationException when run some table api tests which lead these
tests fail.
{code:java}
//PlannerTypeInferenceUtilImpl
private DataType castIfNeeded(
ResolvedExpression child,
PlannerExpression plannerChild,
TypeInformation<?> expectedType) {
TypeInformation<?> actualType = plannerChild.resultType();
if (actualType.equals(expectedType)) {
return child.getOutputDataType();
} else if (TypeCoercion.canSafelyCast(
fromTypeInfoToLogicalType(actualType),
fromTypeInfoToLogicalType(expectedType))) {
return fromLegacyInfoToDataType(expectedType);
} else {
throw new ValidationException(String.format("Incompatible type of argument: %s
Expected: %s",
child,
expectedType));
}
}
{code}
I think table api and SQL should keep same behavior.
> function log(f0,f1) in Table API do not support decimal type
> ---------------------------------------------------------------
>
> Key: FLINK-14036
> URL: https://issues.apache.org/jira/browse/FLINK-14036
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / API, Table SQL / Planner
> Affects Versions: 1.9.0
> Reporter: Leonard Xu
> Priority: Major
> Fix For: 1.10.0
>
>
> function log(f0,f1) in Table API module do not support decimal type, but it
> works in Table SQL module. The following code will run fail:
>
> {code:java}
> testTableApi(
> 'f0.log(f1),
> "log(f0,f1)",
> "2.0")
> override def testData: Row = {
> val testData = new Row(2)
> testData.setField(0, BigDecimal("3").bigDecimal)
> testData.setField(1, 9)
> testData
> }
>
> override def typeInfo: RowTypeInfo = {
> new RowTypeInfo(
> /* 0 */ fromLogicalTypeToTypeInfo(DECIMAL(1, 0)),
> /* 1 */ Types.INT
> )
> }{code}
>
> The real cause is that the return type of *log()* function must be Double
> type,planner will cast all oprands' type to Double Type before function
> execution, however *org.apache.flink.table.planner.typeutils.TypeCoercion*
> can not yet cast Decimal type to Double type。
--
This message was sent by Atlassian Jira
(v8.3.2#803003)