Return-Path: X-Original-To: apmail-drill-dev-archive@www.apache.org Delivered-To: apmail-drill-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 403E918515 for ; Fri, 26 Jun 2015 17:27:05 +0000 (UTC) Received: (qmail 20743 invoked by uid 500); 26 Jun 2015 17:27:05 -0000 Delivered-To: apmail-drill-dev-archive@drill.apache.org Received: (qmail 20695 invoked by uid 500); 26 Jun 2015 17:27:05 -0000 Mailing-List: contact dev-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list dev@drill.apache.org Received: (qmail 20664 invoked by uid 99); 26 Jun 2015 17:27:04 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jun 2015 17:27:04 +0000 Date: Fri, 26 Jun 2015 17:27:04 +0000 (UTC) From: "Deneche A. Hakim (JIRA)" To: dev@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (DRILL-3397) over(partition by A order by A) should be optimized to over(partition by A) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Deneche A. Hakim created DRILL-3397: --------------------------------------- Summary: 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.2.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)