Repository: tajo
Updated Branches:
  refs/heads/master dd7d041ac -> bbee120d9


TAJO-729: PreLogicalPlanVerifier verifies distinct aggregation functions 
incorrectly. (hyunsik)


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

Branch: refs/heads/master
Commit: bbee120d9d0bf7ead68b9fb49a674e1841718cc9
Parents: dd7d041
Author: Hyunsik Choi <[email protected]>
Authored: Fri Apr 4 16:11:14 2014 +0900
Committer: Hyunsik Choi <[email protected]>
Committed: Fri Apr 4 16:11:14 2014 +0900

----------------------------------------------------------------------
 CHANGES.txt                                                 | 3 +++
 .../apache/tajo/engine/planner/PreLogicalPlanVerifier.java  | 2 +-
 .../java/org/apache/tajo/engine/query/TestGroupByQuery.java | 9 +++++++++
 .../queries/TestGroupByQuery/testDistinctAggregation6.sql   | 9 +++++++++
 .../TestGroupByQuery/testDistinctAggregation6.result        | 5 +++++
 5 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/bbee120d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index bbb5e1c..5a24a05 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -304,6 +304,9 @@ Release 0.8.0 - unreleased
 
   BUG FIXES
 
+    TAJO-729: PreLogicalPlanVerifier verifies distinct aggregation functions
+    incorrectly. (hyunsik)
+
     TAJO-719: JUnit test failures. (jinho)
 
     TAJO-713: Missing INET4 in UniformRangePartition. (jihoon)

http://git-wip-us.apache.org/repos/asf/tajo/blob/bbee120d/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PreLogicalPlanVerifier.java
----------------------------------------------------------------------
diff --git 
a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PreLogicalPlanVerifier.java
 
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PreLogicalPlanVerifier.java
index fef9dc1..cadeff4 100644
--- 
a/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PreLogicalPlanVerifier.java
+++ 
b/tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/PreLogicalPlanVerifier.java
@@ -83,7 +83,7 @@ public class PreLogicalPlanVerifier extends 
BaseAlgebraVisitor <PreLogicalPlanVe
         for (GeneralSetFunctionExpr setFunction : exprs) {
           if (distinctValues == null && setFunction.isDistinct()) {
             distinctValues = setFunction.getParams();
-          } else if (distinctValues != null) {
+          } else if (distinctValues != null && setFunction.isDistinct()) {
             if (!Arrays.equals(distinctValues, setFunction.getParams())) {
               Expr [] differences = ObjectArrays.concat(distinctValues, 
setFunction.getParams(), Expr.class);
               throw new PlanningException("different DISTINCT columns are not 
supported yet: "

http://git-wip-us.apache.org/repos/asf/tajo/blob/bbee120d/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestGroupByQuery.java
----------------------------------------------------------------------
diff --git 
a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestGroupByQuery.java
 
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestGroupByQuery.java
index 250d6f4..9e3c375 100644
--- 
a/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestGroupByQuery.java
+++ 
b/tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestGroupByQuery.java
@@ -177,6 +177,15 @@ public class TestGroupByQuery extends QueryTestCaseBase {
   }
 
   @Test
+  public final void testDistinctAggregation6() throws Exception {
+    // select count(distinct l_orderkey), sum(l_orderkey), sum(l_linenumber), 
count(*) as v4 from lineitem
+    // group by l_orderkey;
+    ResultSet res = executeQuery();
+    assertResultSet(res);
+    cleanupQuery(res);
+  }
+
+  @Test
   public final void testDistinctAggregationWithHaving1() throws Exception {
     // select l_linenumber, count(*), count(distinct l_orderkey), sum(distinct 
l_orderkey) from lineitem
     // group by l_linenumber having sum(distinct l_orderkey) >= 6;

http://git-wip-us.apache.org/repos/asf/tajo/blob/bbee120d/tajo-core/tajo-core-backend/src/test/resources/queries/TestGroupByQuery/testDistinctAggregation6.sql
----------------------------------------------------------------------
diff --git 
a/tajo-core/tajo-core-backend/src/test/resources/queries/TestGroupByQuery/testDistinctAggregation6.sql
 
b/tajo-core/tajo-core-backend/src/test/resources/queries/TestGroupByQuery/testDistinctAggregation6.sql
new file mode 100644
index 0000000..242eb18
--- /dev/null
+++ 
b/tajo-core/tajo-core-backend/src/test/resources/queries/TestGroupByQuery/testDistinctAggregation6.sql
@@ -0,0 +1,9 @@
+select
+  count(distinct l_orderkey) as v0,
+  sum(l_orderkey) as v1,
+  sum(l_linenumber) as v2,
+  count(*) as v4
+from
+  lineitem
+group by
+  l_orderkey;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/bbee120d/tajo-core/tajo-core-backend/src/test/resources/results/TestGroupByQuery/testDistinctAggregation6.result
----------------------------------------------------------------------
diff --git 
a/tajo-core/tajo-core-backend/src/test/resources/results/TestGroupByQuery/testDistinctAggregation6.result
 
b/tajo-core/tajo-core-backend/src/test/resources/results/TestGroupByQuery/testDistinctAggregation6.result
new file mode 100644
index 0000000..cd59b8f
--- /dev/null
+++ 
b/tajo-core/tajo-core-backend/src/test/resources/results/TestGroupByQuery/testDistinctAggregation6.result
@@ -0,0 +1,5 @@
+v0,v1,v2,v4
+-------------------------------
+1,2,3,2
+1,2,1,1
+1,6,3,2
\ No newline at end of file

Reply via email to