[
https://issues.apache.org/jira/browse/IMPALA-7255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ian Cook updated IMPALA-7255:
-----------------------------
Description:
Based on the Impala docs and on the behavior of other SQL engines, it's evident
that:
{{round(-15, -1)}} should return {{-20}}
{{round(-150, -2)}} should return {{-200}}
and so on, because negative values at the midpoint between the upper and lower
rounded values are supposed to round to the value farther from zero. However,
in Impala:
{{round(-15, -1)}} returns {{-10}}
{{round(-150, -2)}} returns {{-100}}
and so on. This issue affects cases where both arguments are negative and the
number being rounded is at the midpoint. I believe this issue affects cases
where the first argument has any of the integer data types or the {{FLOAT}} or
{{DOUBLE}} type, but not when it has a {{DECIMAL}} type. This issue seems to
occur regardless of whether the numbers being rounded are specified as
literals, column references, or expressions.
To reproduce this, execute queries like:
{{SELECT round(-15, -1);}}
{{SELECT round(-150, -2);}}
{{SELECT round(cast(-150 AS BIGINT), -2);}}
{{SELECT round(cast(-150 AS DOUBLE), -2);}}
was:
Based on the Impala docs and on the behavior of other SQL engines, it's evident
that:
{{round(-55, -1)}} should return {{-60}}
{{round(-550, -2)}} should return {{-600}}
and so on, because negative values at the midpoint between the upper and lower
rounded values are supposed to round to the value farther from zero. However,
in Impala:
{{round(-55, -1)}} returns {{-50}}
{{round(-550, -2)}} returns {{-500}}
and so on. This issue affects cases where both arguments are negative and the
number being rounded is at the midpoint. I believe this issue affects cases
where the first argument has any of the integer data types or the {{FLOAT}} or
{{DOUBLE}} type, but not when it has a {{DECIMAL}} type. This issue seems to
occur regardless of whether the numbers being rounded are specified as
literals, column references, or expressions.
To reproduce this, execute queries like:
{{SELECT round(-55, -1);}}
{{SELECT round(-550, -2);}}
{{SELECT round(cast(-550 AS BIGINT), -2);}}
{{SELECT round(cast(-550 AS DOUBLE), -2);}}
> Incorrect result rounding midpoint negative numbers to negative precision
> -------------------------------------------------------------------------
>
> Key: IMPALA-7255
> URL: https://issues.apache.org/jira/browse/IMPALA-7255
> Project: IMPALA
> Issue Type: Bug
> Reporter: Ian Cook
> Priority: Major
>
> Based on the Impala docs and on the behavior of other SQL engines, it's
> evident that:
> {{round(-15, -1)}} should return {{-20}}
> {{round(-150, -2)}} should return {{-200}}
> and so on, because negative values at the midpoint between the upper and
> lower rounded values are supposed to round to the value farther from zero.
> However, in Impala:
> {{round(-15, -1)}} returns {{-10}}
> {{round(-150, -2)}} returns {{-100}}
> and so on. This issue affects cases where both arguments are negative and the
> number being rounded is at the midpoint. I believe this issue affects cases
> where the first argument has any of the integer data types or the {{FLOAT}}
> or {{DOUBLE}} type, but not when it has a {{DECIMAL}} type. This issue seems
> to occur regardless of whether the numbers being rounded are specified as
> literals, column references, or expressions.
> To reproduce this, execute queries like:
> {{SELECT round(-15, -1);}}
> {{SELECT round(-150, -2);}}
> {{SELECT round(cast(-150 AS BIGINT), -2);}}
> {{SELECT round(cast(-150 AS DOUBLE), -2);}}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]