Ramin Gharib created FLINK-41569:
------------------------------------

             Summary: IS_NAN built-in function only resolves as ISNAN in SQL
                 Key: FLINK-41569
                 URL: https://issues.apache.org/jira/browse/FLINK-41569
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / API
            Reporter: Ramin Gharib
            Assignee: Ramin Gharib


The built-in function {{IS_NAN}} is documented as {{IS_NAN(value)}}, but SQL 
only resolves it as {{ISNAN}}.

{code:sql}
SELECT IS_NAN(d) FROM (VALUES (CAST('NaN' AS DOUBLE)), (CAST(1 AS DOUBLE))) AS 
t(d);
-- fails: No match found for function signature IS_NAN(<NUMERIC>)

SELECT ISNAN(d) FROM (VALUES (CAST('NaN' AS DOUBLE)), (CAST(1 AS DOUBLE))) AS 
t(d);
-- works: TRUE, FALSE
{code}

||Call||Expected||Actual||
|SQL {{IS_NAN(d)}}|{{TRUE}}, {{FALSE}}|{{No match found for function signature 
IS_NAN(<NUMERIC>)}}|
|SQL {{ISNAN(d)}}|Not a function, it is not documented|{{TRUE}}, {{FALSE}}|
|Table API {{$("d").isNan()}} as SQL string|A call that SQL parses 
back|{{IS_NAN(`d`)}}, which SQL rejects|

*Cause*

{{CoreModule}} registers every built-in function under 
{{getName().toUpperCase()}}. {{IS_NAN}} is defined with 
{{.name("isNan").sqlName("IS_NAN").runtimeClass(...)}}, so SQL finds it only as 
{{ISNAN}}. The {{sqlName}} is used only to print a Table API expression as SQL, 
which is why the Table API prints a name that SQL can't resolve.

Other definitions whose {{sqlName}} differs from {{name()}}, such as 
{{CHAR_LENGTH}}, resolve through their Calcite operators, so they don't have 
this problem.

Compiled plans store the function as {{$ISNAN$1}}, built from {{name()}}.

*Proposal*

Rename the definition to {{.name("IS_NAN")}} and drop {{.sqlName(...)}}. Then 
{{IS_NAN}} resolves in SQL, and the docs, the Table API's SQL string and SQL 
all use one name. {{ISNAN}} stops resolving, and compiled plans store 
{{$IS_NAN$1}}. 2.4.0 is not released yet, so no released compiled plan contains 
{{$ISNAN$1}}. Fixing release-2.4 before 2.4.0 ships keeps {{ISNAN}} out of 
every release.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to