You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Zhixiong Chen (Jira)" <ji...@apache.org> on 2020/02/27 06:04:00 UTC

[jira] [Commented] (CALCITE-3832) decimal cast double throws npe

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

Zhixiong Chen commented on CALCITE-3832:
----------------------------------------

I found in RexToLixTranslator  when decimal cast to double 

the code is : 

if (fromNumber || fromBox == Primitive.CHAR) {
    // Generate "x.shortValue()".
    return Expressions.unbox(operand, toPrimitive);

}

 

> decimal cast double throws npe
> ------------------------------
>
>                 Key: CALCITE-3832
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3832
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.16.0
>            Reporter: Zhixiong Chen
>            Priority: Major
>
> sql like:
> select
> cast(Column1 as DOUBLE) + cast(Column2 as DOUBLE) AS "COLUMN5",
> cast(Column3 as DOUBLE) + cast(Column4 as DOUBLE) AS "COLUMN6"
> from TABLE
> The Column1、Column2、Column3、Column4 type is decimal(19,4)
> But it throw npe in decimal cast to double
> then I find in calcite plan it doesn't  deal with null
> /* 24 */ final java.math.BigDecimal inp14_ = current[14] == null ? (java.math.BigDecimal) null : org.apache.calcite.runtime.SqlFunctions.toBigDecimal(current[14]);
> /* 25 */ final double v = inp14_.doubleValue();
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)