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 2018/03/26 20:39:00 UTC

[jira] [Resolved] (IMPALA-6468) Round() is inconsistent for Decimal and Double

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

Taras Bobrovytsky resolved IMPALA-6468.
---------------------------------------
       Resolution: Fixed
    Fix Version/s: Impala 3.0

{noformat}
commit 8fec1911e52e40aff4cc1de17265bd6803cb13f5
Author: Taras Bobrovytsky <tb...@cloudera.com>
Date: Tue Jan 30 18:21:14 2018 -0800

IMPALA-6230, IMPALA-6468: Fix the output type of round() and related fns

Before this patch, the output type of round() ceil() floor() trunc() was
not always the same as the input type. It was also inconsistent in
general. For example, round(double) returned an integer, but
round(double, int) returned a double.

After looking at other database systems, we decided that the guideline
should be that the output type should be the same as the input type. In
this patch, we change the behavior of the previously mentioned functions
so that if a double is given then a double is returned.

We also modify the rounding behavior to always round away from zero.
Before, we were rounding towards positive infinity in some cases.

Testinging:
- Updated tests
- Ran an exhaustive build which passed.

Cherry-picks: not for 2.x

Change-Id: I77541678012edab70b182378b11ca8753be53f97
Reviewed-on: http://gerrit.cloudera.org:8080/9346
Reviewed-by: Alex Behm <al...@cloudera.com>
Tested-by: Impala Public Jenkins{noformat}

> Round() is inconsistent for Decimal and Double
> ----------------------------------------------
>
>                 Key: IMPALA-6468
>                 URL: https://issues.apache.org/jira/browse/IMPALA-6468
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Backend
>    Affects Versions: Impala 2.11.0
>            Reporter: Taras Bobrovytsky
>            Assignee: Taras Bobrovytsky
>            Priority: Major
>             Fix For: Impala 3.0
>
>
> We round away from zero when rounding decimals:
> {code:java}
> select round(cast(-5.55 as decimal(10, 5)), 1);
> -5.6{code}
>  
> However, we round towards positive infinity for doubles.
> {code:java}
> select round(cast(-5.55 as double), 1);
> -5.5
> select round(cast(5.55 as double), 1);
> 5.6{code}
>  
> This seems inconsistent.



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