You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by jn...@apache.org on 2015/09/11 07:20:14 UTC
[4/6] drill git commit: DRILL-2190, DRILL-2313,
DRILL-2318: Add test cases
DRILL-2190, DRILL-2313, DRILL-2318: Add test cases
Fixes are in CALCITE-634, CALCITE-613, CALCITE-662
Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/e29a1530
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/e29a1530
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/e29a1530
Branch: refs/heads/master
Commit: e29a153076c04939e539c2862b5ef3ec8f96021c
Parents: 24bcca1
Author: Hsuan-Yi Chu <hs...@usc.edu>
Authored: Fri Sep 4 11:35:45 2015 -0700
Committer: Jinfeng Ni <jn...@apache.org>
Committed: Thu Sep 10 17:46:03 2015 -0700
----------------------------------------------------------------------
.../org/apache/drill/TestExampleQueries.java | 69 ++++++++++++++++++++
.../apache/drill/exec/sql/TestWithClause.java | 22 +++++++
2 files changed, 91 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/drill/blob/e29a1530/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 d15cff2..58c7862 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
@@ -1121,4 +1121,73 @@ public class TestExampleQueries extends BaseTestQuery {
.build()
.run();
}
+
+ @Test // see DRILL-2313
+ public void testDistinctOverAggFunctionWithGroupBy() throws Exception {
+ String query1 = "select distinct count(distinct n_nationkey) as col from cp.`tpch/nation.parquet` group by n_regionkey order by 1";
+ String query2 = "select distinct count(distinct n_nationkey) as col from cp.`tpch/nation.parquet` group by n_regionkey order by count(distinct n_nationkey)";
+ String query3 = "select distinct sum(n_nationkey) as col from cp.`tpch/nation.parquet` group by n_regionkey order by 1";
+ String query4 = "select distinct sum(n_nationkey) as col from cp.`tpch/nation.parquet` group by n_regionkey order by col";
+
+ testBuilder()
+ .sqlQuery(query1)
+ .unOrdered()
+ .baselineColumns("col")
+ .baselineValues((long) 5)
+ .build()
+ .run();
+
+ testBuilder()
+ .sqlQuery(query2)
+ .unOrdered()
+ .baselineColumns("col")
+ .baselineValues((long) 5)
+ .build()
+ .run();
+
+ testBuilder()
+ .sqlQuery(query3)
+ .ordered()
+ .baselineColumns("col")
+ .baselineValues((long) 47)
+ .baselineValues((long) 50)
+ .baselineValues((long) 58)
+ .baselineValues((long) 68)
+ .baselineValues((long) 77)
+ .build()
+ .run();
+
+ testBuilder()
+ .sqlQuery(query4)
+ .ordered()
+ .baselineColumns("col")
+ .baselineValues((long) 47)
+ .baselineValues((long) 50)
+ .baselineValues((long) 58)
+ .baselineValues((long) 68)
+ .baselineValues((long) 77)
+ .build()
+ .run();
+ }
+
+ @Test // DRILL-2190
+ public void testDateImplicitCasting() throws Exception {
+ String query = "SELECT birth_date \n" +
+ "FROM cp.`employee.json` \n" +
+ "WHERE birth_date BETWEEN '1920-01-01' AND cast('1931-01-01' AS DATE) \n" +
+ "order by birth_date";
+
+ testBuilder()
+ .sqlQuery(query)
+ .unOrdered()
+ .baselineColumns("birth_date")
+ .baselineValues("1920-04-17")
+ .baselineValues("1921-12-04")
+ .baselineValues("1922-08-10")
+ .baselineValues("1926-10-27")
+ .baselineValues("1928-03-20")
+ .baselineValues("1930-01-08")
+ .build()
+ .run();
+ }
}
http://git-wip-us.apache.org/repos/asf/drill/blob/e29a1530/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestWithClause.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestWithClause.java b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestWithClause.java
index 3a32045..ff04f8c 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestWithClause.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestWithClause.java
@@ -39,4 +39,26 @@ public class TestWithClause extends BaseTestQuery {
"select x, y from alpha");
}
+ @Test // DRILL-2318
+ public void withClauseOrderBy() throws Exception {
+ String query = "WITH x \n" +
+ "AS (SELECT n_nationkey a1 \n" +
+ "FROM cp.`tpch/nation.parquet`) \n" +
+ "SELECT x.a1 \n" +
+ "FROM x \n" +
+ "ORDER BY x.a1 \n" +
+ "limit 5";
+
+ testBuilder()
+ .sqlQuery(query)
+ .ordered()
+ .baselineColumns("a1")
+ .baselineValues(0)
+ .baselineValues(1)
+ .baselineValues(2)
+ .baselineValues(3)
+ .baselineValues(4)
+ .build()
+ .run();
+ }
}