You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Krystal (JIRA)" <ji...@apache.org> on 2016/03/22 20:02:25 UTC

[jira] [Created] (DRILL-4528) AVG() windows function is not optimized for limit 0 queries

Krystal created DRILL-4528:
------------------------------

             Summary: AVG() windows function is not optimized for limit 0 queries
                 Key: DRILL-4528
                 URL: https://issues.apache.org/jira/browse/DRILL-4528
             Project: Apache Drill
          Issue Type: Bug
          Components: Query Planning & Optimization
            Reporter: Krystal
            Assignee: Sean Hsuan-Yi Chu


git.commit.id.abbrev=cee5317

The following sample query contains the avg() windows function that is not optimized when wrapped with limit 0:

select * from (
SELECT AVG(cast( col1 as BIGINT )) OVER(PARTITION BY cast( col4 as TIMESTAMP) ORDER BY cast( col5 as DATE )) FROM `fewRowsAllData_v`) t limit 0

Physical Plan:
{code}
00-00    Screen : rowType = RecordType(ANY EXPR$0): rowcount = 1.0, cumulative cost = {469.1 rows, 5717.190984570043 cpu, 0.0 io, 0.0 network, 1872.0 memory}, id = 5762023
00-01      Project(EXPR$0=[$0]) : rowType = RecordType(ANY EXPR$0): rowcount = 1.0, cumulative cost = {469.0 rows, 5717.090984570043 cpu, 0.0 io, 0.0 network, 1872.0 memory}, id = 5762022
00-02        SelectionVectorRemover : rowType = RecordType(ANY EXPR$0): rowcount = 1.0, cumulative cost = {469.0 rows, 5717.090984570043 cpu, 0.0 io, 0.0 network, 1872.0 memory}, id = 5762021
00-03          Limit(fetch=[0]) : rowType = RecordType(ANY EXPR$0): rowcount = 1.0, cumulative cost = {468.0 rows, 5716.090984570043 cpu, 0.0 io, 0.0 network, 1872.0 memory}, id = 5762020
00-04            Project(EXPR$0=[/(CastHigh($3), $4)]) : rowType = RecordType(ANY EXPR$0): rowcount = 78.0, cumulative cost = {468.0 rows, 5716.090984570043 cpu, 0.0 io, 0.0 network, 1872.0 memory}, id = 5762019
00-05              Window(window#0=[window(partition {2} order by [1] range between UNBOUNDED PRECEDING and CURRENT ROW aggs [SUM($0), COUNT($0)])]) : rowType = RecordType(BIGINT $0, DATE $1, TIMESTAMP(0) $2, BIGINT w0$o0, BIGINT w0$o1): rowcount = 78.0, cumulative cost = {390.0 rows, 5404.090984570043 cpu, 0.0 io, 0.0 network, 1872.0 memory}, id = 5762018
00-06                SelectionVectorRemover : rowType = RecordType(BIGINT $0, DATE $1, TIMESTAMP(0) $2): rowcount = 78.0, cumulative cost = {312.0 rows, 5170.090984570043 cpu, 0.0 io, 0.0 network, 1872.0 memory}, id = 5762017
00-07                  Sort(sort0=[$2], sort1=[$1], dir0=[ASC], dir1=[ASC]) : rowType = RecordType(BIGINT $0, DATE $1, TIMESTAMP(0) $2): rowcount = 78.0, cumulative cost = {234.0 rows, 5092.090984570043 cpu, 0.0 io, 0.0 network, 1872.0 memory}, id = 5762016
00-08                    Project($0=[CAST(CAST($0):BIGINT):BIGINT], $1=[CAST(CAST($1):DATE):DATE], $2=[CAST(CAST($2):TIMESTAMP(0)):TIMESTAMP(0)]) : rowType = RecordType(BIGINT $0, DATE $1, TIMESTAMP(0) $2): rowcount = 78.0, cumulative cost = {156.0 rows, 1170.0 cpu, 0.0 io, 0.0 network, 0.0 memory}, id = 5762015
00-09                      Scan(groupscan=[ParquetGroupScan [entries=[ReadEntryWithPath [path=maprfs:///drill/testdata/window_functions/fewRowsAllData.parquet]], selectionRoot=maprfs:/drill/testdata/window_functions/fewRowsAllData.parquet, numFiles=1, usedMetadataFile=false, columns=[`col1`, `col5`, `col4`]]]) : rowType = RecordType(ANY col1, ANY col5, ANY col4): rowcount = 78.0, cumulative cost = {78.0 rows, 234.0 cpu, 0.0 io, 0.0 network, 0.0 memory}, id = 5762014
{code}



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