You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Jinfeng Ni (JIRA)" <ji...@apache.org> on 2015/02/11 04:04:11 UTC

[jira] [Assigned] (DRILL-2199) Wrong results while using case expression with decimal data type

     [ https://issues.apache.org/jira/browse/DRILL-2199?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jinfeng Ni reassigned DRILL-2199:
---------------------------------

    Assignee: Mehant Baid  (was: Jinfeng Ni)

> Wrong results while using case expression with decimal data type
> ----------------------------------------------------------------
>
>                 Key: DRILL-2199
>                 URL: https://issues.apache.org/jira/browse/DRILL-2199
>             Project: Apache Drill
>          Issue Type: Bug
>            Reporter: Mehant Baid
>            Assignee: Mehant Baid
>         Attachments: DRILL-2199.patch
>
>
> Consider the below SQL statement:
> "select 
> case when true then cast(employee_id as decimal(15, 5)) else cast('0.0' as decimal(5, 2)) end 
> from cp.`employee.json` where employee_id = 1"
> This should return 1.00000 instead Drill returns 100000. In the case statement the first expression (condition expression) is nullable and the else expression is non-nullable. For our codegen to work correctly we make the non-nullable expression also nullable using convertToNullableXHolder() functions. These functions however do not preserve the scale and precision of the input, hence the output we get is the unscaled value of the decimal.
> Fix is to make the converToNullableDecimalHolder() functions preserve the scale and precision by returning the correct major type.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)