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

dalongliu commented on FLINK-35832:
-----------------------------------

Merged in master: 6719efc6b12af62bab93b1a7997a1fe5eab97017

> 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, 1.15.4, 1.16.3, 1.17.2, 1.18.1, 1.20.0, 1.19.1
>            Reporter: Yu Chen
>            Assignee: Dylan He
>            Priority: Critical
>              Labels: pull-request-available
>
> 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