drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amansi...@apache.org
Subject drill git commit: DRILL-1927, DRILL-2966: Issues were resolved in Calcite update. Test cases added
Date Sun, 10 May 2015 21:38:54 GMT
Repository: drill
Updated Branches:
  refs/heads/master 3a294abcc -> 2ea54ebe1


DRILL-1927, DRILL-2966: Issues were resolved in Calcite update. Test cases added


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

Branch: refs/heads/master
Commit: 2ea54ebe14457e57eb5af376a513ade6cc91455d
Parents: 3a294ab
Author: Hsuan-Yi Chu <hsuanyi@usc.edu>
Authored: Mon Mar 23 16:14:38 2015 -0700
Committer: Aman Sinha <asinha@maprtech.com>
Committed: Sun May 10 14:30:01 2015 -0700

----------------------------------------------------------------------
 .../org/apache/drill/TestExampleQueries.java    | 90 ++++++++++++++++++++
 .../testHavingAggFunction/q1.tsv                |  5 ++
 .../testHavingAggFunction/q2.tsv                |  4 +
 .../testHavingAggFunction/q3.tsv                |  5 ++
 4 files changed, 104 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/2ea54ebe/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
index f0f9310..b75f644 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java
@@ -860,4 +860,94 @@ public class TestExampleQueries extends BaseTestQuery{
         .build()
         .run();
   }
+
+  @Test // DRILL-1927
+  public void testGroupByCaseInSubquery() throws Exception {
+    String query1 = "select (case when t.r_regionkey in (3) then 0 else 1 end) as col \n"
+
+        "from cp.`tpch/region.parquet` t \n" +
+        "group by (case when t.r_regionkey in (3) then 0 else 1 end)";
+
+    String query2 = "select sum(case when t.r_regionkey in (3) then 0 else 1 end) as col
\n" +
+        "from cp.`tpch/region.parquet` t";
+
+    String query3 = "select (case when (r_regionkey IN (0, 2, 3, 4)) then 0 else r_regionkey
end) as col1, min(r_regionkey) as col2 \n" +
+        "from cp.`tpch/region.parquet` \n" +
+        "group by (case when (r_regionkey IN (0, 2, 3, 4)) then 0 else r_regionkey end)";
+
+    testBuilder()
+        .sqlQuery(query1)
+        .unOrdered()
+        .baselineColumns("col")
+        .baselineValues(0)
+        .baselineValues(1)
+        .build()
+        .run();
+
+    testBuilder()
+        .sqlQuery(query2)
+        .unOrdered()
+        .baselineColumns("col")
+        .baselineValues((long) 4)
+        .build()
+        .run();
+
+    testBuilder()
+        .sqlQuery(query3)
+        .unOrdered()
+        .baselineColumns("col1", "col2")
+        .baselineValues(0, 0)
+        .baselineValues(1, 1)
+        .build()
+        .run();
+  }
+
+  @Test  // DRILL-2966
+  public void testHavingAggFunction() throws Exception {
+    String query1 = "select n_nationkey as col \n" +
+        "from cp.`tpch/nation.parquet` \n" +
+        "group by n_nationkey \n" +
+        "having sum(case when n_regionkey in (1, 2) then 1 else 0 end) + \n" +
+        "sum(case when n_regionkey in (2, 3) then 1 else 0 end) > 1";
+
+    String query2 = "select n_nationkey as col \n"
+        + "from cp.`tpch/nation.parquet` \n"
+        + "group by n_nationkey \n"
+        + "having n_nationkey in \n"
+            + "(select r_regionkey \n"
+            + "from cp.`tpch/region.parquet` \n"
+            + "group by r_regionkey \n"
+            + "having sum(r_regionkey) > 0)";
+
+    String query3 = "select n_nationkey as col \n"
+        + "from cp.`tpch/nation.parquet` \n"
+        + "group by n_nationkey \n"
+        + "having max(n_regionkey) > ((select min(r_regionkey) from cp.`tpch/region.parquet`)
+ 3)";
+
+    testBuilder()
+        .sqlQuery(query1)
+        .unOrdered()
+        .csvBaselineFile("testframework/testExampleQueries/testHavingAggFunction/q1.tsv")
+        .baselineTypes(TypeProtos.MinorType.INT)
+        .baselineColumns("col")
+        .build()
+        .run();
+
+    testBuilder()
+        .sqlQuery(query2)
+        .unOrdered()
+        .csvBaselineFile("testframework/testExampleQueries/testHavingAggFunction/q2.tsv")
+        .baselineTypes(TypeProtos.MinorType.INT)
+        .baselineColumns("col")
+        .build()
+        .run();
+
+    testBuilder()
+        .sqlQuery(query3)
+        .unOrdered()
+        .csvBaselineFile("testframework/testExampleQueries/testHavingAggFunction/q3.tsv")
+        .baselineTypes(TypeProtos.MinorType.INT)
+        .baselineColumns("col")
+        .build()
+        .run();
+  }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/2ea54ebe/exec/java-exec/src/test/resources/testframework/testExampleQueries/testHavingAggFunction/q1.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/testframework/testExampleQueries/testHavingAggFunction/q1.tsv
b/exec/java-exec/src/test/resources/testframework/testExampleQueries/testHavingAggFunction/q1.tsv
new file mode 100644
index 0000000..b1c286e
--- /dev/null
+++ b/exec/java-exec/src/test/resources/testframework/testExampleQueries/testHavingAggFunction/q1.tsv
@@ -0,0 +1,5 @@
+8
+9
+12
+18
+21
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/2ea54ebe/exec/java-exec/src/test/resources/testframework/testExampleQueries/testHavingAggFunction/q2.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/testframework/testExampleQueries/testHavingAggFunction/q2.tsv
b/exec/java-exec/src/test/resources/testframework/testExampleQueries/testHavingAggFunction/q2.tsv
new file mode 100644
index 0000000..b178657
--- /dev/null
+++ b/exec/java-exec/src/test/resources/testframework/testExampleQueries/testHavingAggFunction/q2.tsv
@@ -0,0 +1,4 @@
+1
+2
+3
+4
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/2ea54ebe/exec/java-exec/src/test/resources/testframework/testExampleQueries/testHavingAggFunction/q3.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/testframework/testExampleQueries/testHavingAggFunction/q3.tsv
b/exec/java-exec/src/test/resources/testframework/testExampleQueries/testHavingAggFunction/q3.tsv
new file mode 100644
index 0000000..0c54016
--- /dev/null
+++ b/exec/java-exec/src/test/resources/testframework/testExampleQueries/testHavingAggFunction/q3.tsv
@@ -0,0 +1,5 @@
+4
+10
+11
+13
+20
\ No newline at end of file


Mime
View raw message