drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From meh...@apache.org
Subject [1/2] drill git commit: DRILL-2438: Fix reduce aggregates rule to not inject additional casts for avg
Date Thu, 26 Mar 2015 20:15:45 GMT
Repository: drill
Updated Branches:
  refs/heads/master 165bb52cb -> 9d92b8e31


DRILL-2438: Fix reduce aggregates rule to not inject additional casts for avg


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/0d118a6d
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/0d118a6d
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/0d118a6d

Branch: refs/heads/master
Commit: 0d118a6ded670889f9217331be0bb5c95eb43000
Parents: 165bb52
Author: Mehant Baid <mehantr@gmail.com>
Authored: Tue Mar 24 17:24:14 2015 -0700
Committer: Mehant Baid <mehantr@gmail.com>
Committed: Thu Mar 26 11:00:22 2015 -0700

----------------------------------------------------------------------
 .../exec/planner/logical/DrillReduceAggregatesRule.java     | 4 +---
 .../apache/drill/exec/fn/impl/TestAggregateFunctions.java   | 9 +++++++++
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/0d118a6d/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 af5c776..d5115c8 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
@@ -352,8 +352,7 @@ public class DrillReduceAggregatesRule extends RelOptRule {
             SqlStdOperatorTable.DIVIDE,
             numeratorRef,
             denominatorRef);
-    return rexBuilder.makeCast(
-        oldCall.getType(), divideRef);
+    return divideRef;
   }
 
   private RexNode reduceSum(
@@ -557,7 +556,6 @@ public class DrillReduceAggregatesRule extends RelOptRule {
           rexBuilder.makeCall(
               SqlStdOperatorTable.POWER, div, half);
     }
-
     return rexBuilder.makeCast(
         oldCall.getType(), result);
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/0d118a6d/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
index 72ad31a..50c62e2 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
@@ -185,4 +185,13 @@ public class TestAggregateFunctions extends BaseTestQuery {
         .go();
   }
 
+  @Test
+  public void testAvgOnKnownType() throws Exception {
+    testBuilder()
+        .sqlQuery("select avg(cast(employee_id as bigint)) as col from cp.`employee.json`")
+        .unOrdered()
+        .baselineColumns("col")
+        .baselineValues(578.9982683982684d)
+        .go();
+  }
 }


Mime
View raw message