You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@impala.apache.org by "Taras Bobrovytsky (JIRA)" <ji...@apache.org> on 2017/11/15 03:56:00 UTC

[jira] [Resolved] (IMPALA-6183) Converting Decimal to Double loses precision

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

Taras Bobrovytsky resolved IMPALA-6183.
---------------------------------------
       Resolution: Fixed
    Fix Version/s: Impala 2.11.0

{code}
commit d1b92c8b525e73fd9dbc91d5e0a1d73a5d402b82
Author: Taras Bobrovytsky <tb...@cloudera.com>
Date:   Tue Nov 14 12:54:19 2017 -0800

    IMPALA-6183: Fix Decimal to Double conversion
    
    When converting a decimal to a double, we incorrectly used the powf()
    function in the backend, which returns a float instead of a double.
    This caused us to lose precision.
    
    We fix the problem by replacing the powf() function with a pow()
    function, which returns a double.
    
    Testing:
    - Added an EE test.
    
    Change-Id: I9bf81d039e5037f22c64a32b328832235aafe9e3
    Reviewed-on: http://gerrit.cloudera.org:8080/8547
    Reviewed-by: Alex Behm <al...@cloudera.com>
    Tested-by: Impala Public Jenkins
{code}

> Converting Decimal to Double loses precision
> --------------------------------------------
>
>                 Key: IMPALA-6183
>                 URL: https://issues.apache.org/jira/browse/IMPALA-6183
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Backend
>    Affects Versions: Impala 2.7.0, Impala 2.8.0, Impala 2.9.0, Impala 2.10.0, Impala 2.11.0
>            Reporter: Taras Bobrovytsky
>            Assignee: Taras Bobrovytsky
>             Fix For: Impala 2.11.0
>
>
> The following query returns a correct result:
> {code}
> select cast(1.1112223334445559 as double)
> {code}
> Result:
> {code}
> 1.111222333444556
> {code}
> However, if we first convert the literal to a decimal, we lose precision.
> {code}
> select cast(cast(1.1112223334445559 as decimal(38, 37)) as double)
> {code}
> Result:
> {code}
> 1.111222340799091
> {code}



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