Yu Chen created FLINK-35832: ------------------------------- Summary: IFNULL returns error 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
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)