drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Khurram Faraaz (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DRILL-4469) SUM window query returns incorrect results over integer data
Date Thu, 10 Mar 2016 06:56:40 GMT

    [ https://issues.apache.org/jira/browse/DRILL-4469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15188805#comment-15188805
] 

Khurram Faraaz commented on DRILL-4469:
---------------------------------------

Another query where the plan looks messed up. COUNT in query is over column c2, however in
the query plan we see that COUNT is being performed over column c1.

{noformat}
0: jdbc:drill:schema=dfs.tmp> explain plan for select count(c2) OVER w as w_count from
( SELECT * FROM t_alltype ORDER BY c1,c2 DESC NULLS LAST ) subquery WINDOW w AS (PARTITION
BY c8 ORDER BY c2 DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
+------+------+
| text | json |
+------+------+
| 00-00    Screen
00-01      Project(w_count=[$0])
00-02        Project(w0$o0=[$2])
00-03          Window(window#0=[window(partition {0} order by [0 DESC-nulls-first] range between
UNBOUNDED PRECEDING and UNBOUNDED FOLLOWING aggs [COUNT($1)])])
00-04            SelectionVectorRemover
00-05              Sort(sort0=[$0], sort1=[$0], dir0=[ASC], dir1=[DESC-nulls-first])
00-06                Project(T7¦¦*=[$0], $1=[ITEM($0, 'c2')])
00-07                  SelectionVectorRemover
00-08                    Sort(sort0=[$1], sort1=[$2], dir0=[ASC], dir1=[DESC-nulls-last])
00-09                      Project(T7¦¦*=[$0], c1=[$1], c2=[$2])
00-10                        Scan(groupscan=[ParquetGroupScan [entries=[ReadEntryWithPath
[path=maprfs:///tmp/t_alltype]], selectionRoot=maprfs:/tmp/t_alltype, numFiles=1, usedMetadataFile=false,
columns=[`*`]]])
{noformat}

> SUM window query returns incorrect results over integer data
> ------------------------------------------------------------
>
>                 Key: DRILL-4469
>                 URL: https://issues.apache.org/jira/browse/DRILL-4469
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Query Planning & Optimization
>    Affects Versions: 1.6.0
>         Environment: 4 node CentOS cluster
>            Reporter: Khurram Faraaz
>            Priority: Critical
>              Labels: window_function
>         Attachments: t_alltype.csv, t_alltype.parquet
>
>
> SUM window query returns incorrect results as compared to Postgres, with or without the
frame clause in the window definition. Note that there is a sub query involved and data in
column c1 is sorted integer data with no nulls.
> Drill 1.6.0 commit ID: 6d5f4983
> Results from Drill 1.6.0
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp> SELECT SUM(c1) OVER w FROM (select * from dfs.tmp.`t_alltype`)
subQry WINDOW w AS (PARTITION BY c8 ORDER BY c1 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED
FOLLOWING);
> +---------+
> | EXPR$0  |
> +---------+
> | 10585   |
> | 10585   |
> | 10585   |
> | 10585   |
> | 10585   |
> | 10585   |
> ...
> | 10585  |
> | 10585  |
> | 10585  |
> +--------+
> 145 rows selected (0.257 seconds)
> {noformat}
> results from Postgres 9.3
> {noformat}
> postgres=# SELECT SUM(c1) OVER w FROM (select * from t_alltype) subQry WINDOW w AS (PARTITION
BY c8 ORDER BY c1 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
>  sum
> ------
>  4499
>  4499
>  4499
>  4499
>  4499
>  4499
> ...
>  5613
>  5613
>  5613
>   473
>   473
>   473
>   473
>   473
> (145 rows)
> {noformat}
> Removing the frame clause from window definition, still results in completely different
results on Postgres vs Drill
> Results from Drill 1.6.0
> {noformat}
> 0: jdbc:drill:schema=dfs.tmp>    SELECT SUM(c1) OVER w FROM (select * from t_alltype)
subQry WINDOW w AS (PARTITION BY c8 ORDER BY c1);
> +---------+
> | EXPR$0  |
> +---------+
> | 10585   |
> | 10585   |
> | 10585   |
> | 10585   |
> | 10585   |
> | 10585   |
> | 10585   |
> | 10585   |
> | 10585   |
> ...
> | 10585  |
> | 10585  |
> | 10585  |
> | 10585  |
> | 10585  |
> +--------+
> 145 rows selected (0.28 seconds)
> {noformat}
> Results from Postgres
> {noformat}
> postgres=# SELECT SUM(c1) OVER w FROM (select * from t_alltype) subQry WINDOW w AS (PARTITION
BY c8 ORDER BY c1);
>  sum
> ------
>     5
>    12
>    21
>    33
>    47
>    62
>    78
>    96
>   115
>   135
>   158
>   182
>   207
>   233
>   260
>   289
> ...
> 4914
>  5051
>  5189
>  5328
>  5470
>  5613
>     8
>    70
>   198
>   332
>   473
> (145 rows)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message