Ramin Gharib created FLINK-40207:
------------------------------------
Summary: Make NaN and Infinity case-insensitive
Key: FLINK-40207
URL: https://issues.apache.org/jira/browse/FLINK-40207
Project: Flink
Issue Type: Bug
Components: Table SQL / Planner
Reporter: Ramin Gharib
Assignee: Ramin Gharib
Currently Flink only accepts case-sensitive {{NaN. }}If we use nan, Nan, or NAN
Flink will fail to parse it. For to reproduce simply write
{code:java}
SELECT CAST('Nan' as FLOAT){code}
You will get
{code:java}
Caused by: java.lang.NumberFormatException: For input string: "Nan" at
java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
at
java.base/jdk.internal.math.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.base/java.lang.Float.parseFloat(Float.java:476) at
org.apache.flink.table.data.binary.BinaryStringDataUtil.toFloat(BinaryStringDataUtil.java:581)
at BatchExecCalc$3.processElement(Unknown Source) at
org.apache.flink.streaming.runtime.tasks.ChainingOutput.pushToOperator(ChainingOutput.java:110)
at
org.apache.flink.streaming.runtime.tasks.ChainingOutput.collect(ChainingOutput.java:79)
at
org.apache.flink.streaming.runtime.tasks.ChainingOutput.collect(ChainingOutput.java:41)
{code}
This is also applied for Infinity
{code:java}
Caused by: java.lang.NumberFormatException: For input string: "-infinity"
{code}
Moreover, we can also allow {{{}-inf{}}}, {{inf}}
Other vendors like Snowflake and Databricks also define them as
case-insensitive:
[https://docs.snowflake.com/en/sql-reference/data-types-numeric#special-values]
[https://docs.databricks.com/aws/en/sql/language-manual/data-types/special-floating-point-values]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)