You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Deneche A. Hakim (JIRA)" <ji...@apache.org> on 2015/06/26 19:27:05 UTC

[jira] [Updated] (DRILL-3397) over(partition by A order by A) should be optimized to over(partition by A)

     [ https://issues.apache.org/jira/browse/DRILL-3397?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Deneche A. Hakim updated DRILL-3397:
------------------------------------
    Fix Version/s:     (was: 1.2.0)
                   1.3.0

> over(partition by A order by A) should be optimized to over(partition by A)
> ---------------------------------------------------------------------------
>
>                 Key: DRILL-3397
>                 URL: https://issues.apache.org/jira/browse/DRILL-3397
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Query Planning & Optimization
>            Reporter: Deneche A. Hakim
>            Assignee: Jinfeng Ni
>             Fix For: 1.3.0
>
>
> although the following queries return the same results, they have different plans: 
> {noformat}
> EXPLAIN PLAN FOR SELECT SUM(salary) OVER(PARTITION BY position_id) FROM cp.`employee.json`;
> 00-00    Screen
> 00-01      Project(EXPR$0=[CASE(>($2, 0), $3, null)])
> 00-02        Window(window#0=[window(partition {1} order by [] range between UNBOUNDED PRECEDING and UNBOUNDED FOLLOWING aggs [COUNT($0), $SUM0($0)])])
> 00-03          SelectionVectorRemover
> 00-04            Sort(sort0=[$1], dir0=[ASC])
> 00-05              Project(salary=[$1], position_id=[$0])
> 00-06                Scan(groupscan=[EasyGroupScan [selectionRoot=/employee.json, numFiles=1, columns=[`salary`, `position_id`], files=[classpath:/employee.json]]])
> {noformat}
> {noformat}
> EXPLAIN PLAN FOR SELECT SUM(salary) OVER(PARTITION BY position_id ORDER BY position_id) FROM cp.`employee.json`;
> 00-00    Screen
> 00-01      Project(EXPR$0=[CASE(>($2, 0), $3, null)])
> 00-02        Window(window#0=[window(partition {1} order by [1] range between UNBOUNDED PRECEDING and CURRENT ROW aggs [COUNT($0), $SUM0($0)])])
> 00-03          SelectionVectorRemover
> 00-04            Sort(sort0=[$1], sort1=[$1], dir0=[ASC], dir1=[ASC])
> 00-05              Project(salary=[$1], position_id=[$0])
> 00-06                Scan(groupscan=[EasyGroupScan [selectionRoot=/employee.json, numFiles=1, columns=[`salary`, `position_id`], files=[classpath:/employee.json]]])
> {noformat}
> Drill should detect such cases and remove the order-by from the plan.



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