You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by "Chao Long (JIRA)" <ji...@apache.org> on 2019/04/30 02:36:00 UTC

[jira] [Commented] (KYLIN-3993) Sum over a case statement fails with integer data type

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

Chao Long commented on KYLIN-3993:
----------------------------------

Hi [~anoop.krishnaswamy], 

Is the return type of sum measure the same as the real type of column 'accountmonthsopen'?

If not, you can take a look at this issue KYLIN-3957, it's similar to yours.

> Sum over a case statement fails with integer data type
> ------------------------------------------------------
>
>                 Key: KYLIN-3993
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3993
>             Project: Kylin
>          Issue Type: Bug
>          Components: Driver - ODBC
>    Affects Versions: v2.6.1
>            Reporter: Anoop Krishnaswamy
>            Priority: Major
>
> Hi,
> When we use sum over a case statement, it works when the field is of a certain type like decimal(19,3). But the same fails when used with integer field:
> This works:
> select sum(case when balance_indicator='1' then cyc_xxx_balanceadbavg else 0 end) , balance_indicator from fct_profit_table_quarterly
> group by balance_indicator
> Whereas the below sql fails
> select sum(case when balance_indicator='1' then accountmonthsopen else 0 end) , balance_indicator from fct_profit_table_quarterly
> group by balance_indicator
>  
> with the error message:
> {color:#b94a48}java.math.BigDecimal cannot be cast to java.lang.Integer while executing SQL: "select sum(case when balance_indicator='1' then accountmonthsopen else 0 end) , balance_indicator from fct_profit_table_quarterly group by balance_indicator LIMIT 50000"{color}
>  
> {color:#b94a48}The difference between 1st sql and 2nd sql being - in the first query the metric used in the case statement is of decimal(19,4) and the metric used in 2nd statement is of type int.{color}
>  
> {color:#b94a48}Kindly help{color}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)