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 91486185E2 for ; Wed, 9 Mar 2016 00:49:43 +0000 (UTC) Received: (qmail 84485 invoked by uid 500); 9 Mar 2016 00:49:43 -0000 Delivered-To: apmail-drill-dev-archive@drill.apache.org Received: (qmail 84440 invoked by uid 500); 9 Mar 2016 00:49:43 -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 84429 invoked by uid 99); 9 Mar 2016 00:49:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Mar 2016 00:49:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id ED805DFA6C; Wed, 9 Mar 2016 00:49:42 +0000 (UTC) From: jinfengni To: dev@drill.apache.org Reply-To: dev@drill.apache.org References: In-Reply-To: Subject: [GitHub] drill pull request: DRILL-4474: Ensure that ConvertCountToDirectSc... Content-Type: text/plain Message-Id: <20160309004942.ED805DFA6C@git1-us-west.apache.org> Date: Wed, 9 Mar 2016 00:49:42 +0000 (UTC) Github user jinfengni commented on a diff in the pull request: https://github.com/apache/drill/pull/416#discussion_r55455931 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/ConvertCountToDirectScan.java --- @@ -117,6 +117,24 @@ public void onMatch(RelOptRuleCall call) { } else if (aggCall.getArgList().size() == 1) { // count(columnName) ==> Agg ( Scan )) ==> columnValueCount int index = aggCall.getArgList().get(0); + + if (proj != null) { + // project in the middle of Agg and Scan : Only when input of AggCall is a RexInputRef in Project, we find the index of Scan's field. + // For instance, + // Agg - count($0) + // \ + // Proj - Exp={$1} + // \ + // Scan (col1, col2). + // return count of "col2" in Scan's metadata, if found. + + if (proj.getProjects().get(index) instanceof RexInputRef) { + index = ((RexInputRef) proj.getProjects().get(index)).getIndex(); --- End diff -- Make sense. Let me add more unit test in the patch. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---