[ https://issues.apache.org/jira/browse/DRILL-2356?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Victoria Markman closed DRILL-2356. ----------------------------------- > 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: Mehant Baid > Priority: Critical > Fix For: 0.9.0 > > Attachments: DRILL-2356.patch, alltypes_with_nulls > > > 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)