Ramin Gharib created FLINK-40160:
------------------------------------

             Summary: Casting 'NaN' to Float or Double throws CompileException
                 Key: FLINK-40160
                 URL: https://issues.apache.org/jira/browse/FLINK-40160
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Planner
            Reporter: Ramin Gharib
            Assignee: Ramin Gharib


Casting {{NaN}} (Not A Number) to float or double is broken. When calling
{code:java}
SELECT CAST('NaN' AS FLOAT){code}
You will get
{code:java}
Caused by: org.codehaus.commons.compiler.CompileException Create breakpoint : 
Line 45, Column 36: Expression "NaNf" is not an rvalue
at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:13228)
at 
org.codehaus.janino.UnitCompiler.toRvalue0rCompileException(UnitCompiler.java:8073)
at org.codehaus.janino.UnitCompiler.getConstantValue2(UnitCompiler.java:6053)
at org.codehaus.janino.UnitCompiler.access$11000(UnitCompiler.java:240)
at 
org.codehaus.janino.UnitCompiler$19$1.visitAmbiguousName(UnitCompiler.java:6004)
at org.codehaus.janino.Java$AmbiguousName.accept(Java.java:4603)
at org.codehaus.janino.UnitCompiler$19.visitLvalve(UnitCompiler.java:6003)
at org.codehaus.janino.Java$Lvalue.accept(Java.java:4528) {code}
Same issue for {{SELECT CAST('NaN' AS DOUBLE).}}

 

 

The fix should be done in the 
[CodeGenUtils|https://github.com/raminqaf/flink/blob/a417739e30e1fa2f40554619c9b35543f2b4d69e/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/CodeGenUtils.scala#L232-L243].
 There we don't respect the Float or Double NaN.



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

Reply via email to