You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Victoria Markman (JIRA)" <ji...@apache.org> on 2015/03/02 19:29:04 UTC
[jira] [Created] (DRILL-2356) Wrong result when ROUND function is
used in expression
Victoria Markman created DRILL-2356:
---------------------------------------
Summary: Wrong result when ROUND function is used in expression
Key: DRILL-2356
URL: https://issues.apache.org/jira/browse/DRILL-2356
Project: Apache Drill
Issue Type: Bug
Components: Functions - Drill
Affects Versions: 0.8.0
Reporter: Victoria Markman
Assignee: Daniel Barclay (Drill)
Priority: Critical
Observe overflow in the expression SUM(ROUND ...)):
{code}
0: jdbc:drill:schema=dfs> select
. . . . . . . . . . . . > sum(c_bigint) as sum_c_bigint,
. . . . . . . . . . . . > sum(ROUND(c_bigint/12))
. . . . . . . . . . . . > from
. . . . . . . . . . . . > alltypes_with_nulls
. . . . . . . . . . . . > group by
. . . . . . . . . . . . > c_varchar,
. . . . . . . . . . . . > c_integer,
. . . . . . . . . . . . > c_date,
. . . . . . . . . . . . > c_time,
. . . . . . . . . . . . > c_boolean;
+--------------+------------+
| sum_c_bigint | EXPR$1 |
+--------------+------------+
| -3477884857818808320 | -2147483648 |
| 0 | 0 |
| 0 | 0 |
| 4465148082249531392 | 2147483647 |
| 4465148082249531392 | 2147483647 |
| -3999734748766273536 | -2147483648 |
| 0 | 0 |
| -449093763428515840 | -2147483648 |
| -1825551161692782592 | -2147483648 |
| -7308685202664980480 | -2147483648 |
| -6772904422084182016 | -2147483648 |
...
...
{code}
Wrapping ROUND around SUM, produces incorrect result as well:
{code}
0: jdbc:drill:schema=dfs> select
. . . . . . . . . . . . > sum(c_bigint) as sum_c_bigint,
. . . . . . . . . . . . > ROUND(sum(c_bigint/12))
. . . . . . . . . . . . > from
. . . . . . . . . . . . > alltypes_with_nulls
. . . . . . . . . . . . > group by
. . . . . . . . . . . . > c_varchar,
. . . . . . . . . . . . > c_integer,
. . . . . . . . . . . . > c_date,
. . . . . . . . . . . . > c_time,
. . . . . . . . . . . . > c_boolean;
+--------------+------------+
| sum_c_bigint | EXPR$1 |
+--------------+------------+
| -3477884857818808320 | -2147483648 |
| 0 | 0 |
| 0 | 0 |
| 4465148082249531392 | 2147483647 |
| 4465148082249531392 | 2147483647 |
| -3999734748766273536 | -2147483648 |
| 0 | 0 |
| -449093763428515840 | -2147483648 |
| -1825551161692782592 | -2147483648 |
| -7308685202664980480 | -2147483648 |
| -6772904422084182016 | -2147483648 |
...
...
{code}
If you remove ROUND function, you get correct result:
{code}
0: jdbc:drill:schema=dfs> select
. . . . . . . . . . . . > sum(c_bigint) as sum_c_bigint,
. . . . . . . . . . . . > sum(c_bigint/12)
. . . . . . . . . . . . > from
. . . . . . . . . . . . > alltypes_with_nulls
. . . . . . . . . . . . > group by
. . . . . . . . . . . . > c_varchar,
. . . . . . . . . . . . > c_integer,
. . . . . . . . . . . . > c_date,
. . . . . . . . . . . . > c_time,
. . . . . . . . . . . . > c_boolean;
+--------------+------------+
| sum_c_bigint | EXPR$1 |
+--------------+------------+
| -3477884857818808320 | -289823738151567360 |
| 0 | 0 |
| 0 | 0 |
| 4465148082249531392 | 372095673520794282 |
| 4465148082249531392 | 372095673520794282 |
| -3999734748766273536 | -333311229063856128 |
| 0 | 0 |
...
...
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)