You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by "Deneche A. Hakim (JIRA)" <ji...@apache.org> on 2015/06/18 23:56:00 UTC
[jira] [Created] (DRILL-3318) SUM(CAST(col as INT)) shows different
results when used in window functions
Deneche A. Hakim created DRILL-3318:
---------------------------------------
Summary: SUM(CAST(col as INT)) shows different results when used in window functions
Key: DRILL-3318
URL: https://issues.apache.org/jira/browse/DRILL-3318
Project: Apache Drill
Issue Type: Bug
Components: Query Planning & Optimization
Affects Versions: 1.1.0
Reporter: Deneche A. Hakim
Assignee: Jinfeng Ni
Priority: Minor
Fix For: Future
I have a parquet file that contains an INT field with large enough values so that the sum of the values overflows the INT limits, and a VARCHAR column with one single value (to force all rows to be part of the same partition).
Computing the sums without casting will give similar results:
{noformat}
SELECT SUM(col_int) OVER(PARTITION BY col_char) FROM dfs.tmp.`3277` LIMIT 1;
+--------------+
| EXPR$0 |
+--------------+
| -3216087191 |
+--------------+
{noformat}
{noformat}
SELECT SUM(col_int) FROM dfs.tmp.`3277`;
+--------------+
| EXPR$0 |
+--------------+
| -3216087191 |
+--------------+
{noformat}
But if we cast the column before doing the sum, the results are now different:
{noformat}
SELECT SUM(CAST(col_int AS INT)) OVER(PARTITION BY col_char) FROM dfs.tmp.`3277` LIMIT 1;
+-------------+
| EXPR$0 |
+-------------+
| 1078880105 |
+-------------+
{noformat}
{noformat}
SELECT SUM(CAST(col_int AS INT)) FROM dfs.tmp.`3277`;
+--------------+
| EXPR$0 |
+--------------+
| -3216087191 |
+--------------+
{noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)