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

Julian Hyde commented on CALCITE-2067:
--------------------------------------

bq. maybe we should instead add separate Calcite type for NaN, Infinity values, 
and don't change existing logic of Calcite's `DOUBLE`?

I agree. We would add an enum with infinity, negative infinity and NaN as its 
values. It's easy to create a RexLiteral of type SYMBOL containing an enum, so 
try that first. The downside to that approach is that you will need to do 
implicit type conversion, so that you can use a value of that type anywhere 
that a DOUBLE could be used. Maybe that type conversion will be too difficult, 
I don't know.

Another approach is to make POS_INF, NEG_INF and NAN parameter-less built-in 
functions (like CURRENT_TIMESTAMP). Then they never need to be literals, and we 
never need to convert their value to BigDecimal. They are functions that just 
evaluate to the  required double (or Double) values.

> RexBuilder can't handle NaN,Infinity double constants
> -----------------------------------------------------
>
>                 Key: CALCITE-2067
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2067
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.13.0
>            Reporter: Volodymyr Tkach
>            Assignee: Julian Hyde
>
> Currently we are working in Drill to allow support for Nan an Infinity values 
> . 
> When using such values with functions we see the NumberFormatException 
> exception. 
> Query example: _select sin(cast('NaN' as float))_
> RexBuilder#clean and other RexBuilder's methods use BigDecimal for handling 
> Double values, that's why we get NumberFormatException for nan,inf values.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to