[
https://issues.apache.org/jira/browse/FLINK-21582?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17296890#comment-17296890
]
Jark Wu commented on FLINK-21582:
---------------------------------
I think we know the root cause, but it's hard to fix. Because all the literals
are not-null. And Calcite think the return value of operationns on literal are
also not-null.
We may need to fix
{{org.apache.calcite.sql.fun.SqlCastFunction#inferReturnType}} if the operand
is literal and the cast-to-type is illegal. However, this rule may change in
the future if we support implicit type conversion (FLIP-154 [1]), and how many
other function do we need to fix? That why I said it may not easy to fix.
[1]:
https://cwiki.apache.org/confluence/display/FLINK/FLIP-154%3A+SQL+Implicit+Type+Coercion
> COALESCE not works when cast a variable return null
> ---------------------------------------------------
>
> Key: FLINK-21582
> URL: https://issues.apache.org/jira/browse/FLINK-21582
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / API
> Affects Versions: 1.11.1
> Environment: Flink1.11.1
>
> Reporter: Jerry
> Priority: Minor
> Attachments: image-2021-03-03-19-48-21-306.png
>
>
> select COALESCE(cast('aa' as int), 0);return NULL
> select COALESCE(NULL, 0); return 0
> The first case works failed, but the second case works successful
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)