From commits-return-4951-apmail-drill-commits-archive=drill.apache.org@drill.apache.org Sat Jun 3 04:45:58 2017 Return-Path: X-Original-To: apmail-drill-commits-archive@www.apache.org Delivered-To: apmail-drill-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3316F1ACDE for ; Sat, 3 Jun 2017 04:45:58 +0000 (UTC) Received: (qmail 75953 invoked by uid 500); 3 Jun 2017 04:45:58 -0000 Delivered-To: apmail-drill-commits-archive@drill.apache.org Received: (qmail 75876 invoked by uid 500); 3 Jun 2017 04:45:58 -0000 Mailing-List: contact commits-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: commits@drill.apache.org Delivered-To: mailing list commits@drill.apache.org Received: (qmail 75420 invoked by uid 99); 3 Jun 2017 04:45:57 -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; Sat, 03 Jun 2017 04:45:57 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0D8F1E9691; Sat, 3 Jun 2017 04:45:57 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jni@apache.org To: commits@drill.apache.org Date: Sat, 03 Jun 2017 04:46:06 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [11/12] drill git commit: DRILL-5537: Display columns alias for queries with sum() when RDBMS storage plugin is enabled DRILL-5537: Display columns alias for queries with sum() when RDBMS storage plugin is enabled close #845 Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/d38917be Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/d38917be Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/d38917be Branch: refs/heads/master Commit: d38917be44c7d98f1b37984e324c781f2a4e25ad Parents: b14e30b Author: Arina Ielchiieva Authored: Thu May 25 13:23:43 2017 +0000 Committer: Jinfeng Ni Committed: Fri Jun 2 21:43:14 2017 -0700 ---------------------------------------------------------------------- .../logical/DrillReduceAggregatesRule.java | 63 ++++++-------------- 1 file changed, 17 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/d38917be/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java index 62d679d..9f8d062 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -161,11 +161,11 @@ public class DrillReduceAggregatesRule extends RelOptRule { List oldCalls = oldAggRel.getAggCallList(); final int nGroups = oldAggRel.getGroupCount(); - List newCalls = new ArrayList(); + List newCalls = new ArrayList<>(); Map aggCallMapping = - new HashMap(); + new HashMap<>(); - List projList = new ArrayList(); + List projList = new ArrayList<>(); // pass through group key for (int i = 0; i < nGroups; ++i) { @@ -179,7 +179,7 @@ public class DrillReduceAggregatesRule extends RelOptRule { // will add an expression to the end, and we will create an extra // project. RelNode input = oldAggRel.getInput(); - List inputExprs = new ArrayList(); + List inputExprs = new ArrayList<>(); for (RelDataTypeField field : input.getRowType().getFieldList()) { inputExprs.add( rexBuilder.makeInputRef( @@ -315,24 +315,11 @@ public class DrillReduceAggregatesRule extends RelOptRule { typeFactory.createTypeWithNullability( avgInputType, avgInputType.isNullable() || nGroups == 0); - // SqlAggFunction sumAgg = new SqlSumAggFunction(sumType); SqlAggFunction sumAgg = new SqlSumEmptyIsZeroAggFunction(); - AggregateCall sumCall = - new AggregateCall( - sumAgg, - oldCall.isDistinct(), - oldCall.getArgList(), - sumType, - null); + AggregateCall sumCall = AggregateCall.create(sumAgg, oldCall.isDistinct(), oldCall.getArgList(), -1, sumType, null); final SqlCountAggFunction countAgg = (SqlCountAggFunction) SqlStdOperatorTable.COUNT; final RelDataType countType = countAgg.getReturnType(typeFactory); - AggregateCall countCall = - new AggregateCall( - countAgg, - oldCall.isDistinct(), - oldCall.getArgList(), - countType, - null); + AggregateCall countCall = AggregateCall.create(countAgg, oldCall.isDistinct(), oldCall.getArgList(), -1, countType, null); RexNode tmpsumRef = rexBuilder.addAggCall( @@ -429,23 +416,10 @@ public class DrillReduceAggregatesRule extends RelOptRule { argType, argType.isNullable()); sumZeroAgg = new SqlSumEmptyIsZeroAggFunction(); } - AggregateCall sumZeroCall = - new AggregateCall( - sumZeroAgg, - oldCall.isDistinct(), - oldCall.getArgList(), - sumType, - null); + AggregateCall sumZeroCall =AggregateCall.create(sumZeroAgg, oldCall.isDistinct(), oldCall.getArgList(), -1, sumType, null); final SqlCountAggFunction countAgg = (SqlCountAggFunction) SqlStdOperatorTable.COUNT; final RelDataType countType = countAgg.getReturnType(typeFactory); - AggregateCall countCall = - new AggregateCall( - countAgg, - oldCall.isDistinct(), - oldCall.getArgList(), - countType, - null); - + AggregateCall countCall = AggregateCall.create(countAgg, oldCall.isDistinct(), oldCall.getArgList(), -1, countType, null); // NOTE: these references are with respect to the output // of newAggRel RexNode sumZeroRef = @@ -524,10 +498,11 @@ public class DrillReduceAggregatesRule extends RelOptRule { argType, true); final AggregateCall sumArgSquaredAggCall = - new AggregateCall( + AggregateCall.create( new SqlSumAggFunction(sumType), oldCall.isDistinct(), ImmutableIntList.of(argSquaredOrdinal), + -1, sumType, null); final RexNode sumArgSquared = @@ -540,10 +515,11 @@ public class DrillReduceAggregatesRule extends RelOptRule { ImmutableList.of(argType)); final AggregateCall sumArgAggCall = - new AggregateCall( + AggregateCall.create( new SqlSumAggFunction(sumType), oldCall.isDistinct(), ImmutableIntList.of(argOrdinal), + -1, sumType, null); final RexNode sumArg = @@ -561,13 +537,7 @@ public class DrillReduceAggregatesRule extends RelOptRule { final SqlCountAggFunction countAgg = (SqlCountAggFunction) SqlStdOperatorTable.COUNT; final RelDataType countType = countAgg.getReturnType(typeFactory); - final AggregateCall countArgAggCall = - new AggregateCall( - countAgg, - oldCall.isDistinct(), - oldCall.getArgList(), - countType, - null); + final AggregateCall countArgAggCall = AggregateCall.create(countAgg, oldCall.isDistinct(), oldCall.getArgList(), -1, countType, null); final RexNode countArg = rexBuilder.addAggCall( countArgAggCall, @@ -719,12 +689,13 @@ public class DrillReduceAggregatesRule extends RelOptRule { final SqlAggFunction sumZeroAgg = new DrillCalciteSqlAggFunctionWrapper( new SqlSumEmptyIsZeroAggFunction(), sumType); AggregateCall sumZeroCall = - new AggregateCall( + AggregateCall.create( sumZeroAgg, oldAggregateCall.isDistinct(), oldAggregateCall.getArgList(), + -1, sumType, - null); + oldAggregateCall.getName()); oldAggRel.getCluster().getRexBuilder() .addAggCall(sumZeroCall, oldAggRel.getGroupCount(),