[ 
https://issues.apache.org/jira/browse/FLINK-35832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17866587#comment-17866587
 ] 

lincoln lee commented on FLINK-35832:
-------------------------------------

[~yunta] Looks like this is the problem that FLINK-30966(`ifnull` was also 
mentioned in FLINK-31003) intended to solve but somehow missed the change. 

> IFNULL returns incorrect result in Flink SQL
> --------------------------------------------
>
>                 Key: FLINK-35832
>                 URL: https://issues.apache.org/jira/browse/FLINK-35832
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 2.0.0
>            Reporter: Yu Chen
>            Priority: Critical
>
> Run following SQL in sql-client:
> The correct result should be '16', but we got '1' on the master.
> {code:java}
> Flink SQL> SET 'sql-client.execution.result-mode' = 'tableau';
> [INFO] Execute statement succeeded.
> Flink SQL> select JSON_VALUE('{"a":16}','$.a'), 
> IFNULL(JSON_VALUE('{"a":16}','$.a'),'0');
> +----+--------------------------------+--------------------------------+
> | op |                         EXPR$0 |                         EXPR$1 |
> +----+--------------------------------+--------------------------------+
> | +I |                             16 |                              1 |
> +----+--------------------------------+--------------------------------+
> Received a total of 1 row (0.30 seconds){code}
>  
> With some quick debugging, I guess it may be caused by 
> [FLINK-24413|https://issues.apache.org/jira/browse/FLINK-24413] which was 
> introduced in Flink version 1.15.
>  
> I think the wrong result '1' was produced because the simplifying SQL 
> procedure assumed that parameter 1 and parameter 2 ('0' was char) of IFNULL 
> were of the same type, and therefore implicitly cast '16' to char, resulting 
> in the incorrect result.
>  
> I have tested the SQL in the following version:
>  
> ||Flink Version||Result||
> |1.13|16,16|
> |1.17|16,1|
> |1.19|16,1|
> |master|16,1|
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to