http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/TestUnionDistinct.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestUnionDistinct.java b/exec/java-exec/src/test/java/org/apache/drill/TestUnionDistinct.java
index 38ab7fb..b76d308 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestUnionDistinct.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestUnionDistinct.java
@@ -25,22 +25,26 @@ import org.apache.drill.categories.SqlTest;
import org.apache.drill.common.exceptions.UserException;
import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.common.types.TypeProtos;
-import org.apache.drill.common.util.FileUtils;
import org.apache.drill.exec.work.foreman.SqlUnsupportedException;
import org.apache.drill.exec.work.foreman.UnsupportedRelOperatorException;
-import org.junit.Ignore;
+import org.apache.drill.test.BaseTestQuery;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import java.nio.file.Paths;
import java.util.List;
@Category({SqlTest.class, OperatorTest.class})
public class TestUnionDistinct extends BaseTestQuery {
-// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestUnionDistinct.class);
-
private static final String sliceTargetSmall = "alter session set `planner.slice_target` = 1";
private static final String sliceTargetDefault = "alter session reset `planner.slice_target`";
+ @BeforeClass
+ public static void setupFiles() {
+ dirTestWatcher.copyResourceToRoot(Paths.get("multilevel"));
+ }
+
@Test // Simple Union over two scans
public void testUnionDistinct1() throws Exception {
String query = "(select n_regionkey from cp.`tpch/nation.parquet`) union (select r_regionkey from cp.`tpch/region.parquet`)";
@@ -183,13 +187,13 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test // Union-Distinct of * column from JSON files in different directories
public void testUnionDistinct9() throws Exception {
- String file0 = FileUtils.getResourceAsFile("/multilevel/json/1994/Q1/orders_94_q1.json").toURI().toString();
- String file1 = FileUtils.getResourceAsFile("/multilevel/json/1995/Q1/orders_95_q1.json").toURI().toString();
- String query = String.format("select o_custkey, o_orderstatus, o_totalprice, o_orderdate, o_orderpriority, o_clerk, o_shippriority, o_comment, o_orderkey from dfs_test.`%s` union \n" +
- "select o_custkey, o_orderstatus, o_totalprice, o_orderdate, o_orderpriority, o_clerk, o_shippriority, o_comment, o_orderkey from dfs_test.`%s`", file0, file1);
+ String file0 = "/multilevel/json/1994/Q1/orders_94_q1.json";
+ String file1 = "/multilevel/json/1995/Q1/orders_95_q1.json";
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select o_custkey, o_orderstatus, o_totalprice, o_orderdate, o_orderpriority, o_clerk, o_shippriority, o_comment, o_orderkey " +
+ "from cp.`%s` union select o_custkey, o_orderstatus, o_totalprice, o_orderdate, o_orderpriority, o_clerk, o_shippriority, o_comment, o_orderkey from cp.`%s`",
+ file0, file1)
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/q9.tsv")
.baselineTypes(TypeProtos.MinorType.BIGINT, TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.FLOAT8, TypeProtos.MinorType.VARCHAR,
@@ -202,12 +206,9 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test // Union-Distinct constant literals
public void testUnionDistinct10() throws Exception {
- String query = "(select n_name, 'LEFT' as LiteralConstant, n_nationkey, '1' as NumberConstant from cp.`tpch/nation.parquet`) \n" +
- "union \n" +
- "(select 'RIGHT', r_name, '2', r_regionkey from cp.`tpch/region.parquet`)";
-
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("(select n_name, 'LEFT' as LiteralConstant, n_nationkey, '1' as NumberConstant from cp.`tpch/nation.parquet`) " +
+ "union (select 'RIGHT', r_name, '2', r_regionkey from cp.`tpch/region.parquet`)")
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/q10.tsv")
.baselineTypes(TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.INT, TypeProtos.MinorType.INT)
@@ -218,17 +219,17 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testUnionDistinctViewExpandableStar() throws Exception {
- test("use dfs_test.tmp");
+ test("use dfs.tmp");
test("create view nation_view_testunion as select n_name, n_nationkey from cp.`tpch/nation.parquet`;");
test("create view region_view_testunion as select r_name, r_regionkey from cp.`tpch/region.parquet`;");
- String query1 = "(select * from dfs_test.tmp.`nation_view_testunion`) \n" +
+ String query1 = "(select * from dfs.tmp.`nation_view_testunion`) \n" +
"union \n" +
- "(select * from dfs_test.tmp.`region_view_testunion`)";
+ "(select * from dfs.tmp.`region_view_testunion`)";
String query2 = "(select r_name, r_regionkey from cp.`tpch/region.parquet`) \n" +
"union \n" +
- "(select * from dfs_test.tmp.`nation_view_testunion`)";
+ "(select * from dfs.tmp.`nation_view_testunion`)";
try {
testBuilder()
@@ -256,11 +257,11 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test(expected = UnsupportedRelOperatorException.class)
public void testUnionDistinctViewUnExpandableStar() throws Exception {
- test("use dfs_test.tmp");
+ test("use dfs.tmp");
test("create view nation_view_testunion as select * from cp.`tpch/nation.parquet`;");
try {
- String query = "(select * from dfs_test.tmp.`nation_view_testunion`) \n" +
+ String query = "(select * from dfs.tmp.`nation_view_testunion`) \n" +
"union (select * from cp.`tpch/region.parquet`)";
test(query);
} catch(UserException ex) {
@@ -273,7 +274,7 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testDiffDataTypesAndModes() throws Exception {
- test("use dfs_test.tmp");
+ test("use dfs.tmp");
test("create view nation_view_testunion as select n_name, n_nationkey from cp.`tpch/nation.parquet`;");
test("create view region_view_testunion as select r_name, r_regionkey from cp.`tpch/region.parquet`;");
@@ -301,14 +302,10 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testDistinctOverUnionDistinctwithFullyQualifiedColumnNames() throws Exception {
- String query = "select distinct sq.x1, sq.x2 \n" +
- "from \n" +
- "((select n_regionkey as a1, n_name as b1 from cp.`tpch/nation.parquet`) \n" +
- "union \n" +
- "(select r_regionkey as a2, r_name as b2 from cp.`tpch/region.parquet`)) as sq(x1,x2)";
-
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select distinct sq.x1, sq.x2 " +
+ "from ((select n_regionkey as a1, n_name as b1 from cp.`tpch/nation.parquet`) " +
+ "union (select r_regionkey as a2, r_name as b2 from cp.`tpch/region.parquet`)) as sq(x1,x2)")
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/q14.tsv")
.baselineTypes(TypeProtos.MinorType.INT, TypeProtos.MinorType.VARCHAR)
@@ -319,12 +316,9 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testUnionDistinctContainsColumnANumericConstant() throws Exception {
- String query = "(select n_nationkey, n_regionkey, n_name from cp.`tpch/nation.parquet` limit 5) \n" +
- "union \n" +
- "(select 1, n_regionkey, 'abc' from cp.`tpch/nation.parquet` limit 5)";
-
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("(select n_nationkey, n_regionkey, n_name from cp.`tpch/nation.parquet` limit 5) " +
+ "union (select 1, n_regionkey, 'abc' from cp.`tpch/nation.parquet` limit 5)")
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/q15.tsv")
.baselineTypes(TypeProtos.MinorType.INT, TypeProtos.MinorType.INT, TypeProtos.MinorType.VARCHAR)
@@ -334,16 +328,9 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testUnionDistinctEmptySides() throws Exception {
- String query1 = "(select n_nationkey, n_regionkey, n_name from cp.`tpch/nation.parquet` limit 0) \n" +
- "union \n" +
- "(select 1, n_regionkey, 'abc' from cp.`tpch/nation.parquet` limit 5)";
-
- String query2 = "(select n_nationkey, n_regionkey, n_name from cp.`tpch/nation.parquet` limit 5) \n" +
- "union \n" +
- "(select 1, n_regionkey, 'abc' from cp.`tpch/nation.parquet` limit 0)";
-
testBuilder()
- .sqlQuery(query1)
+ .sqlQuery("(select n_nationkey, n_regionkey, n_name from cp.`tpch/nation.parquet` limit 0) " +
+ "union (select 1, n_regionkey, 'abc' from cp.`tpch/nation.parquet` limit 5)")
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/q16.tsv")
.baselineTypes(TypeProtos.MinorType.INT, TypeProtos.MinorType.INT, TypeProtos.MinorType.VARCHAR)
@@ -352,7 +339,8 @@ public class TestUnionDistinct extends BaseTestQuery {
.run();
testBuilder()
- .sqlQuery(query2)
+ .sqlQuery("(select n_nationkey, n_regionkey, n_name from cp.`tpch/nation.parquet` limit 5) " +
+ "union (select 1, n_regionkey, 'abc' from cp.`tpch/nation.parquet` limit 0)")
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/q17.tsv")
.baselineTypes(TypeProtos.MinorType.INT, TypeProtos.MinorType.INT, TypeProtos.MinorType.VARCHAR)
@@ -363,23 +351,13 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testAggregationOnUnionDistinctOperator() throws Exception {
- String root = FileUtils.getResourceAsFile("/store/text/data/t.json").toURI().toString();
- String query1 = String.format(
- "(select calc1, max(b1) as `max`, min(b1) as `min`, count(c1) as `count` \n" +
- "from (select a1 + 10 as calc1, b1, c1 from dfs_test.`%s` \n" +
- "union \n" +
- "select a1 + 100 as diff1, b1 as diff2, c1 as diff3 from dfs_test.`%s`) \n" +
- "group by calc1 order by calc1)", root, root);
-
- String query2 = String.format(
- "(select calc1, min(b1) as `min`, max(b1) as `max`, count(c1) as `count` \n" +
- "from (select a1 + 10 as calc1, b1, c1 from dfs_test.`%s` \n" +
- "union \n" +
- "select a1 + 100 as diff1, b1 as diff2, c1 as diff3 from dfs_test.`%s`) \n" +
- "group by calc1 order by calc1)", root, root);
+ String root = "/store/text/data/t.json";
testBuilder()
- .sqlQuery(query1)
+ .sqlQuery("(select calc1, max(b1) as `max`, min(b1) as `min`, count(c1) as `count` " +
+ "from (select a1 + 10 as calc1, b1, c1 from cp.`%s` " +
+ "union select a1 + 100 as diff1, b1 as diff2, c1 as diff3 from cp.`%s`) " +
+ "group by calc1 order by calc1)", root, root)
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/testAggregationOnUnionDistinctOperator_1.tsv")
.baselineTypes(TypeProtos.MinorType.BIGINT, TypeProtos.MinorType.BIGINT, TypeProtos.MinorType.BIGINT, TypeProtos.MinorType.BIGINT)
@@ -388,7 +366,10 @@ public class TestUnionDistinct extends BaseTestQuery {
.run();
testBuilder()
- .sqlQuery(query2)
+ .sqlQuery("(select calc1, min(b1) as `min`, max(b1) as `max`, count(c1) as `count` " +
+ "from (select a1 + 10 as calc1, b1, c1 from cp.`%s` " +
+ "union select a1 + 100 as diff1, b1 as diff2, c1 as diff3 from cp.`%s`) " +
+ "group by calc1 order by calc1)", root, root)
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/testAggregationOnUnionDistinctOperator_2.tsv")
.baselineTypes(TypeProtos.MinorType.BIGINT, TypeProtos.MinorType.BIGINT, TypeProtos.MinorType.BIGINT, TypeProtos.MinorType.BIGINT)
@@ -399,39 +380,18 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test(expected = UserException.class)
public void testUnionDistinctImplicitCastingFailure() throws Exception {
- String rootInt = FileUtils.getResourceAsFile("/store/json/intData.json").toURI().toString();
- String rootBoolean = FileUtils.getResourceAsFile("/store/json/booleanData.json").toURI().toString();
-
- String query = String.format(
- "(select key from dfs_test.`%s` \n" +
- "union \n" +
- "select key from dfs_test.`%s` )", rootInt, rootBoolean);
-
- test(query);
+ test("(select key from cp.`store/json/intData.json` " +
+ "union select key from cp.`store/json/booleanData.json` )");
}
@Test
public void testDateAndTimestampJson() throws Exception {
- String rootDate = FileUtils.getResourceAsFile("/store/json/dateData.json").toURI().toString();
- String rootTimpStmp = FileUtils.getResourceAsFile("/store/json/timeStmpData.json").toURI().toString();
-
- String query1 = String.format(
- "(select max(key) as key from dfs_test.`%s` \n" +
- "union \n" +
- "select key from dfs_test.`%s`)", rootDate, rootTimpStmp);
-
- String query2 = String.format(
- "select key from dfs_test.`%s` \n" +
- "union \n" +
- "select max(key) as key from dfs_test.`%s`", rootDate, rootTimpStmp);
-
- String query3 = String.format(
- "select key from dfs_test.`%s` \n" +
- "union \n" +
- "select max(key) as key from dfs_test.`%s`", rootDate, rootTimpStmp);
+ String rootDate = "/store/json/dateData.json";
+ String rootTimpStmp = "/store/json/timeStmpData.json";
testBuilder()
- .sqlQuery(query1)
+ .sqlQuery("(select max(key) as key from cp.`%s` " +
+ "union select key from cp.`%s`)", rootDate, rootTimpStmp)
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/q18_1.tsv")
.baselineTypes(TypeProtos.MinorType.VARCHAR)
@@ -440,7 +400,8 @@ public class TestUnionDistinct extends BaseTestQuery {
.run();
testBuilder()
- .sqlQuery(query2)
+ .sqlQuery("select key from cp.`%s` " +
+ "union select max(key) as key from cp.`%s`", rootDate, rootTimpStmp)
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/q18_2.tsv")
.baselineTypes(TypeProtos.MinorType.VARCHAR)
@@ -449,7 +410,8 @@ public class TestUnionDistinct extends BaseTestQuery {
.run();
testBuilder()
- .sqlQuery(query3)
+ .sqlQuery("select key from cp.`%s` " +
+ "union select max(key) as key from cp.`%s`", rootDate, rootTimpStmp)
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/q18_3.tsv")
.baselineTypes(TypeProtos.MinorType.VARCHAR)
@@ -460,21 +422,11 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testUnionDistinctOneInputContainsAggFunction() throws Exception {
- String root = FileUtils.getResourceAsFile("/multilevel/csv/1994/Q1/orders_94_q1.csv").toURI().toString();
- String query1 = String.format("select * from ((select count(c1) as ct from (select columns[0] c1 from dfs.`%s`)) \n" +
- "union \n" +
- "(select columns[0] c2 from dfs.`%s`)) order by ct limit 3", root, root);
-
- String query2 = String.format("select * from ((select columns[0] ct from dfs.`%s`) \n" +
- "union \n" +
- "(select count(c1) as c2 from (select columns[0] c1 from dfs.`%s`))) order by ct limit 3", root, root);
-
- String query3 = String.format("select * from ((select count(c1) as ct from (select columns[0] c1 from dfs.`%s`) )\n" +
- "union \n" +
- "(select count(c1) as c2 from (select columns[0] c1 from dfs.`%s`))) order by ct", root, root);
+ String root = "/multilevel/csv/1994/Q1/orders_94_q1.csv";
testBuilder()
- .sqlQuery(query1)
+ .sqlQuery("select * from ((select count(c1) as ct from (select columns[0] c1 from cp.`%s`)) " +
+ "union (select columns[0] c2 from dfs.`%s`)) order by ct limit 3", root, root)
.unOrdered()
.baselineColumns("ct")
.baselineValues((long) 10)
@@ -484,7 +436,8 @@ public class TestUnionDistinct extends BaseTestQuery {
.run();
testBuilder()
- .sqlQuery(query2)
+ .sqlQuery("select * from ((select columns[0] ct from dfs.`%s`) " +
+ "union (select count(c1) as c2 from (select columns[0] c1 from dfs.`%s`))) order by ct limit 3", root, root)
.unOrdered()
.baselineColumns("ct")
.baselineValues((long) 10)
@@ -494,7 +447,8 @@ public class TestUnionDistinct extends BaseTestQuery {
.run();
testBuilder()
- .sqlQuery(query3)
+ .sqlQuery("select * from ((select count(c1) as ct from (select columns[0] c1 from dfs.`%s`))" +
+ "union (select count(c1) as c2 from (select columns[0] c1 from dfs.`%s`))) order by ct", root, root)
.unOrdered()
.baselineColumns("ct")
.baselineValues((long) 10)
@@ -504,11 +458,9 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testUnionDistinctDiffTypesAtPlanning() throws Exception {
- String query = "select count(c1) as ct from (select cast(r_regionkey as int) c1 from cp.`tpch/region.parquet`) \n" +
- "union \n" +
- "(select cast(r_regionkey as int) c2 from cp.`tpch/region.parquet`)";
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select count(c1) as ct from (select cast(r_regionkey as int) c1 from cp.`tpch/region.parquet`) " +
+ "union (select cast(r_regionkey as int) c2 from cp.`tpch/region.parquet`)")
.unOrdered()
.baselineColumns("ct")
.baselineValues((long) 5)
@@ -523,16 +475,9 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testUnionDistinctRightEmptyJson() throws Exception {
- String rootEmpty = FileUtils.getResourceAsFile("/project/pushdown/empty.json").toURI().toString();
- String rootSimple = FileUtils.getResourceAsFile("/store/json/booleanData.json").toURI().toString();
-
- String queryRightEmpty = String.format(
- "select key from dfs_test.`%s` \n" +
- "union \n" +
- "select key from dfs_test.`%s`", rootSimple, rootEmpty);
-
testBuilder()
- .sqlQuery(queryRightEmpty)
+ .sqlQuery("select key from cp.`project/pushdown/empty.json` " +
+ "union select key from cp.`store/json/booleanData.json`")
.unOrdered()
.baselineColumns("key")
.baselineValues(true)
@@ -543,18 +488,9 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testUnionDistinctLeftEmptyJson() throws Exception {
- final String rootEmpty = FileUtils.getResourceAsFile("/project/pushdown/empty.json").toURI().toString();
- final String rootSimple = FileUtils.getResourceAsFile("/store/json/booleanData.json").toURI().toString();
-
- final String queryLeftEmpty = String.format(
- "select key from dfs_test.`%s` " +
- "union " +
- "select key from dfs_test.`%s`",
- rootEmpty,
- rootSimple);
-
testBuilder()
- .sqlQuery(queryLeftEmpty)
+ .sqlQuery("select key from cp.`project/pushdown/empty.json` " +
+ "union select key from cp.`store/json/booleanData.json`")
.unOrdered()
.baselineColumns("key")
.baselineValues(true)
@@ -565,14 +501,7 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testUnionDistinctBothEmptyJson() throws Exception {
- final String rootEmpty = FileUtils.getResourceAsFile("/project/pushdown/empty.json").toURI().toString();
- final String query = String.format(
- "select key from dfs_test.`%s` " +
- "union " +
- "select key from dfs_test.`%s`",
- rootEmpty,
- rootEmpty);
-
+ final String rootEmpty = "project/pushdown/empty.json";
final List<Pair<SchemaPath, TypeProtos.MajorType>> expectedSchema = Lists.newArrayList();
final TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder()
.setMinorType(TypeProtos.MinorType.INT)
@@ -581,7 +510,8 @@ public class TestUnionDistinct extends BaseTestQuery {
expectedSchema.add(Pair.of(SchemaPath.getSimplePath("key"), majorType));
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select key from cp.`%s` union select key from cp.`%s`",
+ rootEmpty, rootEmpty)
.schemaBaseLine(expectedSchema)
.build()
.run();
@@ -589,17 +519,11 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testUnionDistinctRightEmptyDataBatch() throws Exception {
- String rootSimple = FileUtils.getResourceAsFile("/store/json/booleanData.json").toURI().toString();
-
- String queryRightEmptyBatch = String.format(
- "select key from dfs_test.`%s` " +
- "union " +
- "select key from dfs_test.`%s` where 1 = 0",
- rootSimple,
- rootSimple);
+ final String rootSimple = "store/json/booleanData.json";
testBuilder()
- .sqlQuery(queryRightEmptyBatch)
+ .sqlQuery("select key from cp.`%s` union select key from cp.`%s` where 1 = 0",
+ rootSimple, rootSimple)
.unOrdered()
.baselineColumns("key")
.baselineValues(true)
@@ -609,17 +533,11 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testUnionDistinctLeftEmptyDataBatch() throws Exception {
- String rootSimple = FileUtils.getResourceAsFile("/store/json/booleanData.json").toURI().toString();
-
- final String queryLeftBatch = String.format(
- "select key from dfs_test.`%s` where 1 = 0 " +
- "union " +
- "select key from dfs_test.`%s`",
- rootSimple,
- rootSimple);
+ final String rootSimple = "store/json/booleanData.json";
testBuilder()
- .sqlQuery(queryLeftBatch)
+ .sqlQuery("select key from cp.`%s` where 1 = 0 union select key from cp.`%s`",
+ rootSimple, rootSimple)
.unOrdered()
.baselineColumns("key")
.baselineValues(true)
@@ -630,13 +548,7 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testUnionDistinctBothEmptyDataBatch() throws Exception {
- String rootSimple = FileUtils.getResourceAsFile("/store/json/booleanData.json").toURI().toString();
- final String query = String.format(
- "select key from dfs_test.`%s` where 1 = 0 " +
- "union " +
- "select key from dfs_test.`%s` where 1 = 0",
- rootSimple,
- rootSimple);
+ final String rootSimple = "store/json/booleanData.json";
final List<Pair<SchemaPath, TypeProtos.MajorType>> expectedSchema = Lists.newArrayList();
final TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder()
@@ -646,7 +558,9 @@ public class TestUnionDistinct extends BaseTestQuery {
expectedSchema.add(Pair.of(SchemaPath.getSimplePath("key"), majorType));
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select key from cp.`%s` where 1 = 0 " +
+ "union select key from cp.`%s` where 1 = 0",
+ rootSimple, rootSimple)
.schemaBaseLine(expectedSchema)
.build()
.run();
@@ -654,13 +568,11 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testFilterPushDownOverUnionDistinct() throws Exception {
- String query = "select n_regionkey from \n"
- + "(select n_regionkey from cp.`tpch/nation.parquet` union select r_regionkey from cp.`tpch/region.parquet`) \n"
- + "where n_regionkey > 0 and n_regionkey < 2 \n"
- + "order by n_regionkey";
-
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select n_regionkey from "
+ + "(select n_regionkey from cp.`tpch/nation.parquet` union select r_regionkey from cp.`tpch/region.parquet`) "
+ + "where n_regionkey > 0 and n_regionkey < 2 "
+ + "order by n_regionkey")
.ordered()
.baselineColumns("n_regionkey")
.baselineValues(1)
@@ -670,14 +582,11 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testInListPushDownOverUnionDistinct() throws Exception {
- String query = "select n_nationkey \n" +
- "from (select n1.n_nationkey from cp.`tpch/nation.parquet` n1 inner join cp.`tpch/region.parquet` r1 on n1.n_regionkey = r1.r_regionkey \n" +
- "union \n" +
- "select n2.n_nationkey from cp.`tpch/nation.parquet` n2 inner join cp.`tpch/region.parquet` r2 on n2.n_regionkey = r2.r_regionkey) \n" +
- "where n_nationkey in (1, 2)";
-
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select n_nationkey " +
+ "from (select n1.n_nationkey from cp.`tpch/nation.parquet` n1 inner join cp.`tpch/region.parquet` r1 on n1.n_regionkey = r1.r_regionkey " +
+ "union select n2.n_nationkey from cp.`tpch/nation.parquet` n2 inner join cp.`tpch/region.parquet` r2 on n2.n_regionkey = r2.r_regionkey) " +
+ "where n_nationkey in (1, 2)")
.unOrdered()
.baselineColumns("n_nationkey")
.baselineValues(1)
@@ -688,15 +597,13 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testFilterPushDownOverUnionDistinctCSV() throws Exception {
- String root = FileUtils.getResourceAsFile("/multilevel/csv/1994/Q1/orders_94_q1.csv").toURI().toString();
- String query = String.format("select ct \n" +
- "from ((select count(c1) as ct from (select columns[0] c1 from dfs.`%s`)) \n" +
- "union \n" +
- "(select columns[0] c2 from dfs.`%s`)) \n" +
- "where ct < 100", root, root);
+ final String root = "/multilevel/csv/1994/Q1/orders_94_q1.csv";
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select ct " +
+ "from ((select count(c1) as ct from (select columns[0] c1 from cp.`%s`)) " +
+ "union (select columns[0] c2 from cp.`%s`)) " +
+ "where ct < 100", root, root)
.ordered()
.baselineColumns("ct")
.baselineValues((long) 10)
@@ -708,12 +615,10 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testProjectPushDownOverUnionDistinctWithProject() throws Exception {
- String query = "select n_nationkey, n_name from \n" +
- "(select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` \n" +
- "union select r_regionkey, r_name, r_comment from cp.`tpch/region.parquet`)";
-
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select n_nationkey, n_name from " +
+ "(select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` " +
+ "union select r_regionkey, r_name, r_comment from cp.`tpch/region.parquet`)")
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/testProjectPushDownOverUnionDistinctWithProject.tsv")
.baselineTypes(TypeProtos.MinorType.INT, TypeProtos.MinorType.VARCHAR)
@@ -724,12 +629,10 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testProjectPushDownOverUnionDistinctWithoutProject() throws Exception {
- String query = "select n_nationkey from \n" +
- "(select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` \n" +
- "union select r_regionkey, r_name, r_comment from cp.`tpch/region.parquet`)";
-
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select n_nationkey from " +
+ "(select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` " +
+ "union select r_regionkey, r_name, r_comment from cp.`tpch/region.parquet`)")
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/testProjectPushDownOverUnionDistinctWithoutProject.tsv")
.baselineTypes(TypeProtos.MinorType.INT)
@@ -740,13 +643,11 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testProjectWithExpressionPushDownOverUnionDistinct() throws Exception {
- String query = "select 2 * n_nationkey as col from \n" +
- "(select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` \n" +
- "union select r_regionkey, r_name, r_comment from cp.`tpch/region.parquet`)";
-
// Validate the result
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select 2 * n_nationkey as col from " +
+ "(select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` " +
+ "union select r_regionkey, r_name, r_comment from cp.`tpch/region.parquet`)")
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/testProjectWithExpressionPushDownOverUnionDistinct.tsv")
.baselineTypes(TypeProtos.MinorType.INT)
@@ -757,14 +658,11 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testProjectDownOverUnionDistinctImplicitCasting() throws Exception {
- String root = FileUtils.getResourceAsFile("/store/text/data/nations.csv").toURI().toString();
- String query = String.format("select 2 * n_nationkey as col from \n" +
- "(select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` \n" +
- "union select columns[0], columns[1], columns[2] from dfs.`%s`) \n" +
- "order by col limit 10", root);
-
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select 2 * n_nationkey as col from " +
+ "(select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` " +
+ "union select columns[0], columns[1], columns[2] from cp.`store/text/data/nations.csv`) " +
+ "order by col limit 10")
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/testProjectDownOverUnionDistinctImplicitCasting.tsv")
.baselineTypes(TypeProtos.MinorType.INT)
@@ -775,12 +673,10 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testProjectPushDownProjectColumnReorderingAndAlias() throws Exception {
- String query = "select n_comment as col1, n_nationkey as col2, n_name as col3 from \n" +
- "(select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` \n" +
- "union select r_regionkey, r_name, r_comment from cp.`tpch/region.parquet`)";
-
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select n_comment as col1, n_nationkey as col2, n_name as col3 from " +
+ "(select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` " +
+ "union select r_regionkey, r_name, r_comment from cp.`tpch/region.parquet`)")
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/testProjectPushDownProjectColumnReorderingAndAlias.tsv")
.baselineTypes(TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.INT, TypeProtos.MinorType.VARCHAR)
@@ -791,13 +687,11 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test
public void testProjectFiltertPushDownOverUnionDistinct() throws Exception {
- String query = "select n_nationkey from \n" +
- "(select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` \n" +
- "union select r_regionkey, r_name, r_comment from cp.`tpch/region.parquet`) \n" +
- "where n_nationkey > 0 and n_nationkey < 4";
-
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select n_nationkey from " +
+ "(select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` " +
+ "union select r_regionkey, r_name, r_comment from cp.`tpch/region.parquet`) " +
+ "where n_nationkey > 0 and n_nationkey < 4")
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/testProjectFiltertPushDownOverUnionDistinct.tsv")
.baselineTypes(TypeProtos.MinorType.INT)
@@ -808,9 +702,9 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test // DRILL-3296
public void testGroupByUnionDistinct() throws Exception {
- String query = "select n_nationkey from \n" +
- "(select n_nationkey from cp.`tpch/nation.parquet` \n" +
- "union select n_nationkey from cp.`tpch/nation.parquet`) \n" +
+ String query = "select n_nationkey from " +
+ "(select n_nationkey from cp.`tpch/nation.parquet` " +
+ "union select n_nationkey from cp.`tpch/nation.parquet`) " +
"group by n_nationkey";
@@ -833,11 +727,11 @@ public class TestUnionDistinct extends BaseTestQuery {
@Test // DRILL-4147 // union-distinct base case
public void testDrill4147_1() throws Exception {
- final String l = FileUtils.getResourceAsFile("/multilevel/parquet/1994").toURI().toString();
- final String r = FileUtils.getResourceAsFile("/multilevel/parquet/1995").toURI().toString();
+ final String l = "/multilevel/parquet/1994";
+ final String r = "/multilevel/parquet/1995";
- final String query = String.format("SELECT o_custkey FROM dfs_test.`%s` \n" +
- "Union distinct SELECT o_custkey FROM dfs_test.`%s`", l, r);
+ final String query = String.format("SELECT o_custkey FROM dfs.`%s` \n" +
+ "Union distinct SELECT o_custkey FROM dfs.`%s`", l, r);
// Validate the plan
final String[] expectedPlan = {"(?s)UnionExchange.*HashAgg.*HashToRandomExchange.*UnionAll.*"};
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/TestUtf8SupportInQueryString.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestUtf8SupportInQueryString.java b/exec/java-exec/src/test/java/org/apache/drill/TestUtf8SupportInQueryString.java
index e8573f8..8dfddde 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestUtf8SupportInQueryString.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestUtf8SupportInQueryString.java
@@ -22,6 +22,7 @@ import mockit.MockUp;
import mockit.integration.junit4.JMockit;
import org.apache.calcite.util.SaffronProperties;
import org.apache.drill.common.exceptions.UserRemoteException;
+import org.apache.drill.test.BaseTestQuery;
import org.junit.Test;
import org.junit.runner.RunWith;
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/DrillSeparatePlanningTest.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/DrillSeparatePlanningTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/DrillSeparatePlanningTest.java
index 41b5a73..c99f0a7 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/DrillSeparatePlanningTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/DrillSeparatePlanningTest.java
@@ -20,6 +20,7 @@ package org.apache.drill.exec;
import static org.junit.Assert.*;
import io.netty.buffer.DrillBuf;
+import java.nio.file.Paths;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -27,12 +28,11 @@ import java.util.Map.Entry;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.PlannerTest;
import org.apache.drill.categories.SlowTest;
import org.apache.drill.common.DrillAutoCloseables;
import org.apache.drill.common.exceptions.UserException;
-import org.apache.drill.common.util.TestTools;
import org.apache.drill.exec.client.DrillClient;
import org.apache.drill.exec.client.PrintingResultsListener;
import org.apache.drill.exec.client.QuerySubmitter.Format;
@@ -55,6 +55,7 @@ import org.apache.drill.exec.rpc.user.QueryDataBatch;
import org.apache.drill.exec.rpc.user.UserResultsListener;
import org.apache.drill.exec.util.VectorUtil;
import org.apache.drill.exec.vector.ValueVector;
+import org.junit.BeforeClass;
import org.junit.Test;
import com.google.common.collect.Lists;
@@ -67,20 +68,11 @@ import org.junit.experimental.categories.Category;
*/
@Category({SlowTest.class, PlannerTest.class})
public class DrillSeparatePlanningTest extends BaseTestQuery {
-
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillSeparatePlanningTest.class);
-
- static final String WORKING_PATH = TestTools.getWorkingPath();
- static final String TEST_RES_PATH = WORKING_PATH + "/src/test/resources";
-
- //final String query = "SELECT sales_city, COUNT(*) cnt FROM cp.`region.json` GROUP BY sales_city";
- //final String query = "SELECT * FROM cp.`employee.json` where employee_id > 1 and employee_id < 1000";
- //final String query = "SELECT o_orderkey, o_custkey FROM dfs.tmp.`multilevel` where dir0 = 1995 and o_orderkey > 100 and o_orderkey < 1000 limit 5";
- //final String query = "SELECT sum(o_totalprice) FROM dfs.tmp.`multilevel` where dir0 = 1995 and o_orderkey > 100 and o_orderkey < 1000";
- //final String query = "SELECT o_orderkey FROM dfs.tmp.`multilevel` order by o_orderkey";
- //final String query = "SELECT dir1, sum(o_totalprice) FROM dfs.tmp.`multilevel` where dir0 = 1995 group by dir1 order by dir1";
- //final String query = String.format("SELECT dir0, sum(o_totalprice) FROM dfs_test.`%s/multilevel/json` group by dir0 order by dir0", TEST_RES_PATH);
-
+ @BeforeClass
+ public static void setupFiles() {
+ dirTestWatcher.copyResourceToRoot(Paths.get("multilevel", "json"));
+ dirTestWatcher.copyResourceToRoot(Paths.get("multilevel", "csv"));
+ }
@Test(timeout=60000)
public void testSingleFragmentQuery() throws Exception {
@@ -98,7 +90,7 @@ public class DrillSeparatePlanningTest extends BaseTestQuery {
@Test(timeout=60000)
public void testMultiMinorFragmentSimpleQuery() throws Exception {
- final String query = String.format("SELECT o_orderkey FROM dfs_test.`%s/multilevel/json`", TEST_RES_PATH);
+ final String query = "SELECT o_orderkey FROM dfs.`multilevel/json`";
QueryPlanFragments planFragments = getFragmentsHelper(query);
@@ -115,7 +107,7 @@ public class DrillSeparatePlanningTest extends BaseTestQuery {
@Test(timeout=60000)
public void testMultiMinorFragmentComplexQuery() throws Exception {
- final String query = String.format("SELECT dir0, sum(o_totalprice) FROM dfs_test.`%s/multilevel/json` group by dir0 order by dir0", TEST_RES_PATH);
+ final String query = "SELECT dir0, sum(o_totalprice) FROM dfs.`multilevel/json` group by dir0 order by dir0";
QueryPlanFragments planFragments = getFragmentsHelper(query);
@@ -128,12 +120,11 @@ public class DrillSeparatePlanningTest extends BaseTestQuery {
}
getResultsHelper(planFragments);
-
}
@Test(timeout=60000)
public void testPlanningNoSplit() throws Exception {
- final String query = String.format("SELECT dir0, sum(o_totalprice) FROM dfs_test.`%s/multilevel/json` group by dir0 order by dir0", TEST_RES_PATH);
+ final String query = "SELECT dir0, sum(o_totalprice) FROM dfs.`multilevel/json` group by dir0 order by dir0";
updateTestCluster(2, config);
@@ -154,12 +145,11 @@ public class DrillSeparatePlanningTest extends BaseTestQuery {
assertFalse(rootFragment.getLeafFragment());
getCombinedResultsHelper(planFragments);
-
}
@Test(timeout=60000)
public void testPlanningNegative() throws Exception {
- final String query = String.format("SELECT dir0, sum(o_totalprice) FROM dfs_test.`%s/multilevel/json` group by dir0 order by dir0", TEST_RES_PATH);
+ final String query = "SELECT dir0, sum(o_totalprice) FROM dfs.`multilevel/json` group by dir0 order by dir0";
updateTestCluster(2, config);
// LOGICAL is not supported
@@ -177,7 +167,7 @@ public class DrillSeparatePlanningTest extends BaseTestQuery {
@Test(timeout=60000)
public void testPlanning() throws Exception {
- final String query = String.format("SELECT dir0, columns[3] FROM dfs_test.`%s/multilevel/csv` order by dir0", TEST_RES_PATH);
+ final String query = "SELECT dir0, columns[3] FROM dfs.`multilevel/csv` order by dir0";
updateTestCluster(2, config);
@@ -187,8 +177,6 @@ public class DrillSeparatePlanningTest extends BaseTestQuery {
}
AwaitableUserResultsListener listener =
new AwaitableUserResultsListener(new PrintingResultsListener(client.getConfig(), Format.TSV, VectorUtil.DEFAULT_COLUMN_WIDTH));
- //AwaitableUserResultsListener listener =
- // new AwaitableUserResultsListener(new SilentListener());
client.runQuery(QueryType.SQL, query, listener);
@SuppressWarnings("unused")
int rows = listener.await();
@@ -251,8 +239,6 @@ public class DrillSeparatePlanningTest extends BaseTestQuery {
List<PlanFragment> fragmentList = Lists.newArrayList();
fragmentList.add(fragment);
- //AwaitableUserResultsListener listener =
- // new AwaitableUserResultsListener(new PrintingResultsListener(client.getConfig(), Format.TSV, VectorUtil.DEFAULT_COLUMN_WIDTH));
AwaitableUserResultsListener listener =
new AwaitableUserResultsListener(new SilentListener());
fragmentClient.runQuery(QueryType.EXECUTION, fragmentList, listener);
@@ -267,9 +253,6 @@ public class DrillSeparatePlanningTest extends BaseTestQuery {
@SuppressWarnings("unused")
AwaitableUserResultsListener listenerBits =
new AwaitableUserResultsListener(myListener);
-
- //AwaitableUserResultsListener listener =
- // new AwaitableUserResultsListener(new PrintingResultsListener(client.getConfig(), Format.TSV, VectorUtil.DEFAULT_COLUMN_WIDTH));
AwaitableUserResultsListener listener =
new AwaitableUserResultsListener(new SilentListener());
client.runQuery(QueryType.EXECUTION, planFragments.getFragmentsList(), listener);
@@ -348,6 +331,5 @@ public class DrillSeparatePlanningTest extends BaseTestQuery {
@Override
public void queryCompleted(QueryState state) {
}
-
}
}
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/ExecTest.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/ExecTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/ExecTest.java
index 418e4a4..9ade940 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/ExecTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/ExecTest.java
@@ -18,14 +18,12 @@
package org.apache.drill.exec;
import com.codahale.metrics.MetricRegistry;
-import com.google.common.io.Files;
import mockit.Mock;
import mockit.MockUp;
import mockit.NonStrictExpectations;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
-import org.apache.commons.io.FileUtils;
import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.common.expression.LogicalExpression;
import org.apache.drill.common.expression.parser.ExprLexer;
@@ -47,7 +45,6 @@ import org.joda.time.DateTimeUtils;
import org.joda.time.DateTimeZone;
import org.junit.After;
import org.junit.BeforeClass;
-import java.io.File;
import java.io.IOException;
import java.text.DateFormatSymbols;
import java.util.Locale;
@@ -88,23 +85,6 @@ public class ExecTest extends DrillTest {
return FileSystem.get(configuration);
}
- /**
- * Create a temp directory to store the given <i>dirName</i>.
- * Directory will be deleted on exit.
- * @param dirName directory name
- * @return Full path including temp parent directory and given directory name.
- */
- public static String getTempDir(final String dirName) {
- final File dir = Files.createTempDir();
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- FileUtils.deleteQuietly(dir);
- }
- });
- return dir.getAbsolutePath() + File.separator + dirName;
- }
-
protected void mockDrillbitContext(final DrillbitContext bitContext) throws Exception {
new NonStrictExpectations() {{
bitContext.getMetrics(); result = new MetricRegistry();
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/TestEmptyInputSql.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/TestEmptyInputSql.java b/exec/java-exec/src/test/java/org/apache/drill/exec/TestEmptyInputSql.java
index 0351250..b691d94 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/TestEmptyInputSql.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/TestEmptyInputSql.java
@@ -20,11 +20,10 @@ package org.apache.drill.exec;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.tuple.Pair;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.UnlikelyTest;
import org.apache.drill.common.expression.SchemaPath;
import org.apache.drill.common.types.TypeProtos;
-import org.apache.drill.common.util.FileUtils;
import org.apache.drill.exec.record.BatchSchema;
import org.apache.drill.test.rowSet.SchemaBuilder;
import org.junit.Test;
@@ -47,16 +46,13 @@ public class TestEmptyInputSql extends BaseTestQuery {
*/
@Test
public void testQueryEmptyJson() throws Exception {
- final String rootEmpty = FileUtils.getResourceAsFile(SINGLE_EMPTY_JSON).toURI().toString();
- final String query = String.format("select key, key + 100 as key2 from dfs_test.`%s` ", rootEmpty);
-
final BatchSchema expectedSchema = new SchemaBuilder()
.addNullable("key", TypeProtos.MinorType.INT)
.addNullable("key2", TypeProtos.MinorType.INT)
.build();
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select key, key + 100 as key2 from cp.`%s`", SINGLE_EMPTY_JSON)
.schemaBaseLine(expectedSchema)
.build()
.run();
@@ -69,22 +65,17 @@ public class TestEmptyInputSql extends BaseTestQuery {
*/
@Test
public void testQueryStarColEmptyJson() throws Exception {
- final String rootEmpty = FileUtils.getResourceAsFile(SINGLE_EMPTY_JSON).toURI().toString();
- final String query1 = String.format("select * from dfs_test.`%s` ", rootEmpty);
-
final BatchSchema expectedSchema = new SchemaBuilder()
.build();
testBuilder()
- .sqlQuery(query1)
+ .sqlQuery("select * from cp.`%s` ", SINGLE_EMPTY_JSON)
.schemaBaseLine(expectedSchema)
.build()
.run();
- final String query2 = String.format("select *, * from dfs_test.`%s` ", rootEmpty);
-
testBuilder()
- .sqlQuery(query2)
+ .sqlQuery("select *, * from cp.`%s` ", SINGLE_EMPTY_JSON)
.schemaBaseLine(expectedSchema)
.build()
.run();
@@ -97,21 +88,16 @@ public class TestEmptyInputSql extends BaseTestQuery {
*/
@Test
public void testQueryQualifiedStarColEmptyJson() throws Exception {
- final String rootEmpty = FileUtils.getResourceAsFile(SINGLE_EMPTY_JSON).toURI().toString();
- final String query1 = String.format("select foo.* from dfs_test.`%s` as foo", rootEmpty);
-
final List<Pair<SchemaPath, TypeProtos.MajorType>> expectedSchema = Lists.newArrayList();
testBuilder()
- .sqlQuery(query1)
+ .sqlQuery("select foo.* from cp.`%s` as foo", SINGLE_EMPTY_JSON)
.schemaBaseLine(expectedSchema)
.build()
.run();
- final String query2 = String.format("select foo.*, foo.* from dfs_test.`%s` as foo", rootEmpty);
-
testBuilder()
- .sqlQuery(query2)
+ .sqlQuery("select foo.*, foo.* from cp.`%s` as foo", SINGLE_EMPTY_JSON)
.schemaBaseLine(expectedSchema)
.build()
.run();
@@ -120,9 +106,6 @@ public class TestEmptyInputSql extends BaseTestQuery {
@Test
public void testQueryMapArrayEmptyJson() throws Exception {
- final String rootEmpty = FileUtils.getResourceAsFile(SINGLE_EMPTY_JSON).toURI().toString();
- final String query = String.format("select foo.a.b as col1, foo.columns[2] as col2, foo.bar.columns[3] as col3 from dfs_test.`%s` as foo", rootEmpty);
-
final BatchSchema expectedSchema = new SchemaBuilder()
.addNullable("col1", TypeProtos.MinorType.INT)
.addNullable("col2", TypeProtos.MinorType.INT)
@@ -130,7 +113,7 @@ public class TestEmptyInputSql extends BaseTestQuery {
.build();
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select foo.a.b as col1, foo.columns[2] as col2, foo.bar.columns[3] as col3 from cp.`%s` as foo", SINGLE_EMPTY_JSON)
.schemaBaseLine(expectedSchema)
.build()
.run();
@@ -144,12 +127,6 @@ public class TestEmptyInputSql extends BaseTestQuery {
*/
@Test
public void testQueryConstExprEmptyJson() throws Exception {
- final String rootEmpty = FileUtils.getResourceAsFile(SINGLE_EMPTY_JSON).toURI().toString();
- final String query = String.format("select 1.0 + 100.0 as key, "
- + " cast(100 as varchar(100)) as name, "
- + " cast(columns as varchar(100)) as name2 "
- + " from dfs_test.`%s` ", rootEmpty);
-
final BatchSchema expectedSchema = new SchemaBuilder()
.add("key", TypeProtos.MinorType.FLOAT8)
.add("name", TypeProtos.MinorType.VARCHAR, 100)
@@ -157,7 +134,10 @@ public class TestEmptyInputSql extends BaseTestQuery {
.build();
testBuilder()
- .sqlQuery(query)
+ .sqlQuery("select 1.0 + 100.0 as key, "
+ + " cast(100 as varchar(100)) as name, "
+ + " cast(columns as varchar(100)) as name2 "
+ + " from cp.`%s` ", SINGLE_EMPTY_JSON)
.schemaBaseLine(expectedSchema)
.build()
.run();
@@ -169,14 +149,11 @@ public class TestEmptyInputSql extends BaseTestQuery {
*/
@Test
public void testQueryEmptyCsvH() throws Exception {
- final String rootEmpty = FileUtils.getResourceAsFile(SINGLE_EMPTY_CSVH).toURI().toString();
- final String query1 = String.format("select * from dfs_test.`%s` ", rootEmpty);
-
final BatchSchema expectedSchema = new SchemaBuilder()
.build();
testBuilder()
- .sqlQuery(query1)
+ .sqlQuery("select * from cp.`%s`", SINGLE_EMPTY_CSVH)
.schemaBaseLine(expectedSchema)
.build()
.run();
@@ -189,15 +166,12 @@ public class TestEmptyInputSql extends BaseTestQuery {
*/
@Test
public void testQueryEmptyCsv() throws Exception {
- final String rootEmpty = FileUtils.getResourceAsFile(SINGLE_EMPTY_CSV).toURI().toString();
- final String query1 = String.format("select * from dfs_test.`%s` ", rootEmpty);
-
final BatchSchema expectedSchema = new SchemaBuilder()
.addArray("columns", TypeProtos.MinorType.VARCHAR)
.build();
testBuilder()
- .sqlQuery(query1)
+ .sqlQuery("select * from cp.`%s`", SINGLE_EMPTY_CSV)
.schemaBaseLine(expectedSchema)
.build()
.run();
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/TestQueriesOnLargeFile.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/TestQueriesOnLargeFile.java b/exec/java-exec/src/test/java/org/apache/drill/exec/TestQueriesOnLargeFile.java
index 0a24073..44cdbc0 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/TestQueriesOnLargeFile.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/TestQueriesOnLargeFile.java
@@ -24,12 +24,11 @@ import java.io.File;
import java.io.PrintWriter;
import java.util.List;
-import org.apache.drill.BaseTestQuery;
-import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.test.BaseTestQuery;
+import org.apache.drill.common.util.DrillFileUtils;
import org.apache.drill.exec.record.RecordBatchLoader;
import org.apache.drill.exec.rpc.user.QueryDataBatch;
import org.apache.drill.exec.vector.BigIntVector;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -37,25 +36,13 @@ import com.google.common.base.Charsets;
import com.google.common.io.Files;
public class TestQueriesOnLargeFile extends BaseTestQuery {
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestQueriesOnLargeFile.class);
-
private static File dataFile = null;
private static int NUM_RECORDS = 15000;
@BeforeClass
public static void generateTestData() throws Exception {
// Generate a json file with NUM_RECORDS number of records
- while (true) {
- dataFile = File.createTempFile("drill-json", ".json");
- if (dataFile.exists()) {
- boolean success = dataFile.delete();
- if (success) {
- break;
- }
- }
- logger.trace("retry creating tmp file");
- }
-
+ dataFile = File.createTempFile("drill-json", ".json", dirTestWatcher.getRootDir());
PrintWriter printWriter = new PrintWriter(dataFile);
for (int i=1; i<=NUM_RECORDS; i++) {
@@ -73,7 +60,7 @@ public class TestQueriesOnLargeFile extends BaseTestQuery {
@Test
public void testRead() throws Exception {
List<QueryDataBatch> results = testSqlWithResults(
- String.format("SELECT count(*) FROM dfs_test.`default`.`%s`", dataFile.getPath()));
+ String.format("SELECT count(*) FROM dfs.`default`.`%s`", dataFile.getName()));
RecordBatchLoader batchLoader = new RecordBatchLoader(getAllocator());
@@ -94,7 +81,7 @@ public class TestQueriesOnLargeFile extends BaseTestQuery {
@Test
public void testMergingReceiver() throws Exception {
- String plan = Files.toString(FileUtils.getResourceAsFile("/largefiles/merging_receiver_large_data.json"),
+ String plan = Files.toString(DrillFileUtils.getResourceAsFile("/largefiles/merging_receiver_large_data.json"),
Charsets.UTF_8).replace("#{TEST_FILE}", escapeJsonString(dataFile.getPath()));
List<QueryDataBatch> results = testPhysicalWithResults(plan);
@@ -107,13 +94,4 @@ public class TestQueriesOnLargeFile extends BaseTestQuery {
assertTrue(String.format("Number of records in output is wrong: expected=%d, actual=%s",
NUM_RECORDS, recordsInOutput), NUM_RECORDS == recordsInOutput);
}
-
- @AfterClass
- public static void deleteTestData() throws Exception {
- if (dataFile != null) {
- if (dataFile.exists()) {
- org.apache.commons.io.FileUtils.forceDelete(dataFile);
- }
- }
- }
}
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/TestRepeatedReaders.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/TestRepeatedReaders.java b/exec/java-exec/src/test/java/org/apache/drill/exec/TestRepeatedReaders.java
index 63c3be5..6c00d81 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/TestRepeatedReaders.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/TestRepeatedReaders.java
@@ -18,49 +18,22 @@
package org.apache.drill.exec;
-import org.apache.drill.BaseTestQuery;
-import org.apache.drill.categories.UnlikelyTest;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.junit.BeforeClass;
+import org.apache.drill.test.BaseTestQuery;
import org.junit.Test;
-import org.junit.experimental.categories.Category;
public class TestRepeatedReaders extends BaseTestQuery {
- static FileSystem fs;
-
- @BeforeClass
- public static void initFs() throws Exception {
- fs = getLocalFileSystem();
- }
-
- private static void deleteTableIfExists(String tableName) {
- try {
- Path path = new Path(getDfsTestTmpSchemaLocation(), tableName);
- if (fs.exists(path)) {
- fs.delete(path, true);
- }
- } catch (Exception e) {
- // ignore exceptions.
- }
- }
-
private void createAndQuery(String datafile) throws Exception {
String query = String.format("select * from cp.`parquet/%s`", datafile);
String tableName = "test_repeated_readers_"+datafile;
- try {
- test("create table dfs_test.tmp.`%s` as %s", tableName, query);
+ test("create table dfs.tmp.`%s` as %s", tableName, query);
- testBuilder()
- .sqlQuery("select * from dfs_test.tmp.`%s` d", tableName)
- .ordered()
- .jsonBaselineFile("parquet/" + datafile)
- .go();
- } finally {
- deleteTableIfExists(tableName);
- }
+ testBuilder()
+ .sqlQuery("select * from dfs.tmp.`%s` d", tableName)
+ .ordered()
+ .jsonBaselineFile("parquet/" + datafile)
+ .go();
}
@Test //DRILL-2292
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
index bd616c7..7d7f4a5 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
@@ -17,29 +17,34 @@
*/
package org.apache.drill.exec;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.UnlikelyTest;
import org.apache.drill.common.exceptions.UserException;
-import org.apache.drill.common.util.FileUtils;
-import org.apache.drill.common.util.TestTools;
+import org.apache.drill.common.util.DrillFileUtils;
import org.apache.drill.exec.proto.UserBitShared;
import org.apache.drill.exec.work.foreman.SqlUnsupportedException;
import org.apache.drill.exec.work.foreman.UnsupportedFunctionException;
import org.apache.drill.PlanTestBase;
import org.apache.drill.test.UserExceptionMatcher;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-public class TestWindowFunctions extends BaseTestQuery {
- static final String WORKING_PATH = TestTools.getWorkingPath();
- static final String TEST_RES_PATH = WORKING_PATH + "/src/test/resources";
+import java.nio.file.Paths;
+public class TestWindowFunctions extends BaseTestQuery {
private static void throwAsUnsupportedException(UserException ex) throws Exception {
SqlUnsupportedException.errorClassNameToException(ex.getOrCreatePBError(false).getException().getExceptionClass());
throw ex;
}
+ @BeforeClass
+ public static void setupTestFiles() {
+ dirTestWatcher.copyResourceToRoot(Paths.get("multilevel/parquet"));
+ dirTestWatcher.copyResourceToRoot(Paths.get("window"));
+ }
+
@Test // DRILL-3196
public void testSinglePartition() throws Exception {
final String query = "select sum(n_nationKey) over(partition by n_nationKey) as col1, count(*) over(partition by n_nationKey) as col2 \n" +
@@ -240,7 +245,7 @@ public class TestWindowFunctions extends BaseTestQuery {
"from testWindowGroupByOnView \n" +
"group by b";
- test("use dfs_test.tmp");
+ test("use dfs.tmp");
test(createView);
test(query);
} finally {
@@ -406,7 +411,7 @@ public class TestWindowFunctions extends BaseTestQuery {
@Test // DRILL-3298
public void testCountEmptyPartitionByWithExchange() throws Exception {
- String query = String.format("select count(*) over (order by o_orderpriority) as cnt from dfs.`%s/multilevel/parquet` where o_custkey < 100", TEST_RES_PATH);
+ String query = "select count(*) over (order by o_orderpriority) as cnt from dfs.`multilevel/parquet` where o_custkey < 100";
try {
// Validate the plan
final String[] expectedPlan = {"Window.*partition \\{\\} order by \\[0\\].*COUNT\\(\\)",
@@ -508,9 +513,9 @@ public class TestWindowFunctions extends BaseTestQuery {
@Test
public void testCompoundIdentifierInWindowDefinition() throws Exception {
- String root = FileUtils.getResourceAsFile("/multilevel/csv/1994/Q1/orders_94_q1.csv").toURI().toString();
+ String root = DrillFileUtils.getResourceAsFile("/multilevel/csv/1994/Q1/orders_94_q1.csv").toURI().toString();
String query = String.format("SELECT count(*) OVER w as col1, count(*) OVER w as col2 \n" +
- "FROM dfs_test.`%s` \n" +
+ "FROM dfs.`%s` \n" +
"WINDOW w AS (PARTITION BY columns[1] ORDER BY columns[0] DESC)", root);
// Validate the plan
@@ -559,7 +564,7 @@ public class TestWindowFunctions extends BaseTestQuery {
@Test // DRILL-3404
public void testWindowSumAggIsNotNull() throws Exception {
- String query = String.format("select count(*) cnt from (select sum ( c1 ) over ( partition by c2 order by c1 asc nulls first ) w_sum from dfs.`%s/window/table_with_nulls.parquet` ) sub_query where w_sum is not null", TEST_RES_PATH);
+ String query = "select count(*) cnt from (select sum ( c1 ) over ( partition by c2 order by c1 asc nulls first ) w_sum from dfs.`window/table_with_nulls.parquet` ) sub_query where w_sum is not null";
// Validate the plan
final String[] expectedPlan = {"Window.*partition \\{1\\} order by \\[0 ASC-nulls-first\\].*SUM\\(\\$0\\)",
@@ -604,11 +609,11 @@ public class TestWindowFunctions extends BaseTestQuery {
@Test // DRILL-3567
public void testMultiplePartitions1() throws Exception {
- String root = FileUtils.getResourceAsFile("/store/text/data/t.json").toURI().toString();
+ String root = DrillFileUtils.getResourceAsFile("/store/text/data/t.json").toURI().toString();
String query = String.format("select count(*) over(partition by b1 order by c1) as count1, \n" +
"sum(a1) over(partition by b1 order by c1) as sum1, \n" +
"count(*) over(partition by a1 order by c1) as count2 \n" +
- "from dfs_test.`%s`", root);
+ "from dfs.`%s`", root);
// Validate the plan
final String[] expectedPlan = {"Window.*partition \\{2\\} order by \\[1\\].*COUNT\\(\\)",
@@ -637,11 +642,11 @@ public class TestWindowFunctions extends BaseTestQuery {
@Test // DRILL-3567
public void testMultiplePartitions2() throws Exception {
- String root = FileUtils.getResourceAsFile("/store/text/data/t.json").toURI().toString();
+ String root = DrillFileUtils.getResourceAsFile("/store/text/data/t.json").toURI().toString();
String query = String.format("select count(*) over(partition by b1 order by c1) as count1, \n" +
"count(*) over(partition by a1 order by c1) as count2, \n" +
"sum(a1) over(partition by b1 order by c1) as sum1 \n" +
- "from dfs_test.`%s`", root);
+ "from dfs.`%s`", root);
// Validate the plan
final String[] expectedPlan = {"Window.*partition \\{2\\} order by \\[1\\].*COUNT\\(\\)",
@@ -670,9 +675,9 @@ public class TestWindowFunctions extends BaseTestQuery {
@Test // see DRILL-3574
public void testWithAndWithoutPartitions() throws Exception {
- String root = FileUtils.getResourceAsFile("/store/text/data/t.json").toURI().toString();
+ String root = DrillFileUtils.getResourceAsFile("/store/text/data/t.json").toURI().toString();
String query = String.format("select sum(a1) over(partition by b1, c1) as s1, sum(a1) over() as s2 \n" +
- "from dfs_test.`%s` \n" +
+ "from dfs.`%s` \n" +
"order by a1", root);
test("alter session set `planner.slice_target` = 1");
@@ -701,10 +706,10 @@ public class TestWindowFunctions extends BaseTestQuery {
@Test // see DRILL-3657
public void testConstantsInMultiplePartitions() throws Exception {
- String root = FileUtils.getResourceAsFile("/store/text/data/t.json").toURI().toString();
+ String root = DrillFileUtils.getResourceAsFile("/store/text/data/t.json").toURI().toString();
String query = String.format(
"select sum(1) over(partition by b1 order by a1) as sum1, sum(1) over(partition by a1) as sum2, rank() over(order by b1) as rank1, rank() over(order by 1) as rank2 \n" +
- "from dfs_test.`%s` \n" +
+ "from dfs.`%s` \n" +
"order by 1, 2, 3, 4", root);
// Validate the plan
@@ -735,9 +740,9 @@ public class TestWindowFunctions extends BaseTestQuery {
@Test // DRILL-3580
public void testExpressionInWindowFunction() throws Exception {
- String root = FileUtils.getResourceAsFile("/store/text/data/t.json").toURI().toString();
+ String root = DrillFileUtils.getResourceAsFile("/store/text/data/t.json").toURI().toString();
String query = String.format("select a1, b1, sum(b1) over (partition by a1) as c1, sum(a1 + b1) over (partition by a1) as c2\n" +
- "from dfs_test.`%s`", root);
+ "from dfs.`%s`", root);
// Validate the plan
final String[] expectedPlan = {"Window\\(window#0=\\[window\\(partition \\{0\\} order by \\[\\].*\\[SUM\\(\\$1\\), SUM\\(\\$2\\)\\]"};
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/cache/TestWriteToDisk.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/cache/TestWriteToDisk.java b/exec/java-exec/src/test/java/org/apache/drill/exec/cache/TestWriteToDisk.java
index f94cf21..6e53d10 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/cache/TestWriteToDisk.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/cache/TestWriteToDisk.java
@@ -24,7 +24,7 @@ import com.google.common.io.Files;
import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.common.types.TypeProtos;
import org.apache.drill.common.types.Types;
-import org.apache.drill.common.util.TestTools;
+import org.apache.drill.test.TestTools;
import org.apache.drill.exec.ExecTest;
import org.apache.drill.exec.expr.TypeHelper;
import org.apache.drill.exec.record.MaterializedField;
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/client/DumpCatTest.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/client/DumpCatTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/client/DumpCatTest.java
index 3dc31ca..63957f4 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/client/DumpCatTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/client/DumpCatTest.java
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertTrue;
import java.io.FileInputStream;
import org.apache.drill.common.config.DrillConfig;
-import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.common.util.DrillFileUtils;
import org.apache.drill.exec.ExecConstants;
import org.apache.drill.exec.ExecTest;
import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry;
@@ -64,7 +64,7 @@ public class DumpCatTest extends ExecTest {
mockDrillbitContext(bitContext);
final PhysicalPlanReader reader = defaultPhysicalPlanReader(c);
- final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/trace/simple_trace.json"), Charsets.UTF_8));
+ final PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(DrillFileUtils.getResourceAsFile("/trace/simple_trace.json"), Charsets.UTF_8));
final FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c);
final FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry);
final SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next()));
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestClassTransformation.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestClassTransformation.java b/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestClassTransformation.java
index b941816..97dfd6b 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestClassTransformation.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestClassTransformation.java
@@ -19,7 +19,7 @@ package org.apache.drill.exec.compile;
import java.io.IOException;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.exec.compile.ClassTransformer.ClassSet;
import org.apache.drill.exec.compile.sig.GeneratorMapping;
import org.apache.drill.exec.compile.sig.MappingSet;
@@ -121,7 +121,7 @@ public class TestClassTransformation extends BaseTestQuery {
private <T, X extends T> CodeGenerator<T> newCodeGenerator(Class<T> iface, Class<X> impl) {
final TemplateClassDefinition<T> template = new TemplateClassDefinition<T>(iface, impl);
- CodeGenerator<T> cg = CodeGenerator.get(template, getDrillbitContext().getFunctionImplementationRegistry(), getDrillbitContext().getOptionManager());
+ CodeGenerator<T> cg = CodeGenerator.get(template, getDrillbitContext().getOptionManager());
cg.plainJavaCapable(true);
ClassGenerator<T> root = cg.getRoot();
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestEvaluationVisitor.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestEvaluationVisitor.java b/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestEvaluationVisitor.java
index 6b16b26..3c41c81 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestEvaluationVisitor.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestEvaluationVisitor.java
@@ -45,8 +45,8 @@ public class TestEvaluationVisitor {
DrillConfig c = DrillConfig.create();
FunctionImplementationRegistry reg = new FunctionImplementationRegistry(c);
- EvaluationVisitor v = new EvaluationVisitor(reg);
- CodeGenerator<?> g = CodeGenerator.get(Projector.TEMPLATE_DEFINITION, reg, null);
+ EvaluationVisitor v = new EvaluationVisitor();
+ CodeGenerator<?> g = CodeGenerator.get(Projector.TEMPLATE_DEFINITION, null);
SchemaPath path = (SchemaPath) getExpr("a.b[4][2].c[6]");
TypedFieldId id = TypedFieldId.newBuilder() //
@@ -75,13 +75,6 @@ public class TestEvaluationVisitor {
private LogicalExpression getExpr(String expr) throws Exception{
ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr));
CommonTokenStream tokens = new CommonTokenStream(lexer);
-
-// tokens.fill();
-// for(Token t : (List<Token>) tokens.getTokens()){
-// System.out.println(t + "" + t.getType());
-// }
-// tokens.rewind();
-
ExprParser parser = new ExprParser(tokens);
parse_return ret = parser.parse();
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestLargeFileCompilation.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestLargeFileCompilation.java b/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestLargeFileCompilation.java
index 1903f35..bec6744 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestLargeFileCompilation.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestLargeFileCompilation.java
@@ -17,13 +17,16 @@
*/
package org.apache.drill.exec.compile;
-import org.apache.drill.BaseTestQuery;
-import org.apache.drill.common.util.TestTools;
+import org.apache.drill.categories.SlowTest;
+import org.apache.drill.test.BaseTestQuery;
+import org.apache.drill.test.TestTools;
import org.apache.drill.exec.ExecConstants;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
import org.junit.rules.TestRule;
+@Category(SlowTest.class)
public class TestLargeFileCompilation extends BaseTestQuery {
@Rule public final TestRule TIMEOUT = TestTools.getTimeoutRule(150000); // 150secs
@@ -120,7 +123,7 @@ public class TestLargeFileCompilation extends BaseTestQuery {
@Test
public void testTEXT_WRITER() throws Exception {
testNoResult("alter session set `%s`='JDK'", ClassCompilerSelector.JAVA_COMPILER_OPTION);
- testNoResult("use dfs_test.tmp");
+ testNoResult("use dfs.tmp");
testNoResult("alter session set `%s`='csv'", ExecConstants.OUTPUT_FORMAT_OPTION);
testNoResult(LARGE_QUERY_WRITER, "wide_table_csv");
}
@@ -128,7 +131,7 @@ public class TestLargeFileCompilation extends BaseTestQuery {
@Test
public void testPARQUET_WRITER() throws Exception {
testNoResult("alter session set `%s`='JDK'", ClassCompilerSelector.JAVA_COMPILER_OPTION);
- testNoResult("use dfs_test.tmp");
+ testNoResult("use dfs.tmp");
testNoResult("alter session set `%s`='parquet'", ExecConstants.OUTPUT_FORMAT_OPTION);
testNoResult(ITERATION_COUNT, LARGE_QUERY_WRITER, "wide_table_parquet");
}
@@ -170,7 +173,7 @@ public class TestLargeFileCompilation extends BaseTestQuery {
testNoResult("alter session set `%s`='JDK'", ClassCompilerSelector.JAVA_COMPILER_OPTION);
testNoResult("alter session set `planner.enable_mergejoin` = false");
testNoResult("alter session set `planner.enable_nestedloopjoin` = false");
- testNoResult("use dfs_test.tmp");
+ testNoResult("use dfs.tmp");
testNoResult(LARGE_TABLE_WRITER, tableName);
testNoResult(QUERY_WITH_JOIN, tableName);
} finally {
@@ -188,7 +191,7 @@ public class TestLargeFileCompilation extends BaseTestQuery {
testNoResult("alter session set `%s`='JDK'", ClassCompilerSelector.JAVA_COMPILER_OPTION);
testNoResult("alter session set `planner.enable_hashjoin` = false");
testNoResult("alter session set `planner.enable_nestedloopjoin` = false");
- testNoResult("use dfs_test.tmp");
+ testNoResult("use dfs.tmp");
testNoResult(LARGE_TABLE_WRITER, tableName);
testNoResult(QUERY_WITH_JOIN, tableName);
} finally {
@@ -207,7 +210,7 @@ public class TestLargeFileCompilation extends BaseTestQuery {
testNoResult("alter session set `planner.enable_nljoin_for_scalar_only` = false");
testNoResult("alter session set `planner.enable_hashjoin` = false");
testNoResult("alter session set `planner.enable_mergejoin` = false");
- testNoResult("use dfs_test.tmp");
+ testNoResult("use dfs.tmp");
testNoResult(LARGE_TABLE_WRITER, tableName);
testNoResult(QUERY_WITH_JOIN, tableName);
} finally {
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java
index af2ee46..fbbb4c8 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java
@@ -23,9 +23,6 @@ import mockit.Injectable;
import mockit.NonStrict;
import mockit.NonStrictExpectations;
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.CommonTokenStream;
-import org.antlr.runtime.RecognitionException;
import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.common.exceptions.ExpressionParsingException;
import org.apache.drill.common.expression.ErrorCollector;
@@ -33,9 +30,6 @@ import org.apache.drill.common.expression.ErrorCollectorImpl;
import org.apache.drill.common.expression.ExpressionPosition;
import org.apache.drill.common.expression.LogicalExpression;
import org.apache.drill.common.expression.SchemaPath;
-import org.apache.drill.common.expression.parser.ExprLexer;
-import org.apache.drill.common.expression.parser.ExprParser;
-import org.apache.drill.common.expression.parser.ExprParser.parse_return;
import org.apache.drill.common.types.TypeProtos;
import org.apache.drill.common.types.TypeProtos.MinorType;
import org.apache.drill.common.types.Types;
@@ -130,7 +124,7 @@ public class ExpressionTest extends ExecTest {
}
FunctionImplementationRegistry funcReg = new FunctionImplementationRegistry(DrillConfig.create());
- final ClassGenerator<Projector> cg = CodeGenerator.get(Projector.TEMPLATE_DEFINITION, funcReg, null).getRoot();
+ final ClassGenerator<Projector> cg = CodeGenerator.get(Projector.TEMPLATE_DEFINITION, null).getRoot();
cg.addExpr(new ValueVectorWriteExpression(new TypedFieldId(materializedExpr.getMajorType(), -1), materializedExpr));
return cg.getCodeGenerator().generateAndGet();
}
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestLogicalExprSerDe.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestLogicalExprSerDe.java b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestLogicalExprSerDe.java
index 3ddf776..bd465df 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestLogicalExprSerDe.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestLogicalExprSerDe.java
@@ -18,7 +18,7 @@ package org.apache.drill.exec.expr;
* limitations under the License.
*/
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.UnlikelyTest;
import org.apache.drill.exec.ExecConstants;
import org.junit.AfterClass;
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestSchemaPathMaterialization.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestSchemaPathMaterialization.java b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestSchemaPathMaterialization.java
index b7c6614..bae200c 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestSchemaPathMaterialization.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/TestSchemaPathMaterialization.java
@@ -17,18 +17,26 @@
*/
package org.apache.drill.exec.expr;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.PlannerTest;
import org.apache.drill.categories.SqlTest;
import org.apache.drill.categories.UnlikelyTest;
import org.apache.drill.exec.proto.UserBitShared;
+import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import java.nio.file.Paths;
+
@Category({SqlTest.class, PlannerTest.class})
public class TestSchemaPathMaterialization extends BaseTestQuery {
+ @BeforeClass
+ public static void setupFiles() {
+ dirTestWatcher.copyResourceToRoot(Paths.get("complex", "json", "multiple"));
+ }
+
@Test
public void testSingleProjectionFromMultiLevelRepeatedList() throws Exception {
final String query = "select t.odd[2][0][0] v1 " +
@@ -90,7 +98,7 @@ public class TestSchemaPathMaterialization extends BaseTestQuery {
@Test //DRILL-1962
@Category(UnlikelyTest.class)
public void testProjectionMultipleFiles() throws Exception {
- final String query="select t.oooa.oa.oab.oabc[1].rowValue1 rowValue from dfs.`${WORKING_PATH}/src/test/resources/complex/json/multiple/*.json` t";
+ final String query="select t.oooa.oa.oab.oabc[1].rowValue1 rowValue from dfs.`complex/json/multiple/*.json` t";
testBuilder()
.sqlQuery(query)
@@ -102,7 +110,7 @@ public class TestSchemaPathMaterialization extends BaseTestQuery {
@Test //DRILL-4264
@Category(UnlikelyTest.class)
public void testFieldNameWithDot() throws Exception {
- final String tableName = "dfs_test.tmp.table_with_dot_field";
+ final String tableName = "dfs.tmp.table_with_dot_field";
try {
test("create table %s as select o_custkey as `x.y.z` from cp.`tpch/orders.parquet`", tableName);
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/FunctionInitializerTest.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/FunctionInitializerTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/FunctionInitializerTest.java
index 3beef0d..c2d4bdb 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/FunctionInitializerTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/FunctionInitializerTest.java
@@ -22,7 +22,7 @@ import mockit.Mock;
import mockit.MockUp;
import mockit.integration.junit4.JMockit;
import org.apache.drill.categories.SqlFunctionTest;
-import org.apache.drill.common.util.TestTools;
+import org.apache.drill.test.TestTools;
import org.apache.drill.exec.util.JarUtil;
import org.codehaus.janino.Java;
import org.junit.BeforeClass;
@@ -30,9 +30,9 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
-import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
+import java.nio.file.Path;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -56,10 +56,12 @@ public class FunctionInitializerTest {
@BeforeClass
public static void init() throws Exception {
- File jars = new File(TestTools.getWorkingPath(), "/src/test/resources/jars");
+ Path jars = TestTools.WORKING_PATH
+ .resolve(TestTools.TEST_RESOURCES)
+ .resolve("jars");
String binaryName = "DrillUDF-1.0.jar";
String sourceName = JarUtil.getSourceName(binaryName);
- URL[] urls = {new File(jars, binaryName).toURI().toURL(), new File(jars, sourceName).toURI().toURL()};
+ URL[] urls = {jars.resolve(binaryName).toUri().toURL(), jars.resolve(sourceName).toUri().toURL()};
classLoader = new URLClassLoader(urls);
}
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/impl/TestStringFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/impl/TestStringFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/impl/TestStringFunctions.java
index a8a69e1..dfb74da 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/impl/TestStringFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/expr/fn/impl/TestStringFunctions.java
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertTrue;
import mockit.integration.junit4.JMockit;
import org.apache.commons.io.FileUtils;
-import org.apache.drill.BaseTestQuery;
+import org.apache.drill.test.BaseTestQuery;
import org.apache.drill.categories.SqlFunctionTest;
import org.apache.drill.exec.util.Text;
import org.junit.Ignore;
@@ -1408,22 +1408,13 @@ public class TestStringFunctions extends BaseTestQuery {
@Test // DRILL-5424
public void testReverseLongVarChars() throws Exception {
- File path = new File(BaseTestQuery.getTempDir("input"));
- try {
- path.mkdirs();
- String pathString = path.toPath().toString();
-
- try (BufferedWriter writer = new BufferedWriter(new FileWriter(new File(path, "table_with_long_varchars.json")))) {
- for (int i = 0; i < 10; i++) {
- writer.write("{ \"a\": \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\"}");
- }
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter(new File(dirTestWatcher.getRootDir(), "table_with_long_varchars.json")))) {
+ for (int i = 0; i < 10; i++) {
+ writer.write("{ \"a\": \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\"}");
}
-
- test("select reverse(a) from dfs_test.`%s/table_with_long_varchars.json` t", pathString);
-
- } finally {
- FileUtils.deleteQuietly(path);
}
+
+ test("select reverse(a) from dfs.`table_with_long_varchars.json` t");
}
@Test
http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunction.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunction.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunction.java
index 3d7bac0..e7cdf44 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunction.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunction.java
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
import org.apache.drill.categories.OperatorTest;
-import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.common.util.DrillFileUtils;
import org.apache.drill.exec.client.DrillClient;
import org.apache.drill.exec.pop.PopUnitTestBase;
import org.apache.drill.exec.proto.UserBitShared.QueryType;
@@ -52,7 +52,7 @@ public class TestAggregateFunction extends PopUnitTestBase {
bit.run();
client.connect();
List<QueryDataBatch> results = client.runQuery(QueryType.PHYSICAL,
- Files.toString(FileUtils.getResourceAsFile(planPath), Charsets.UTF_8).replace("#{TEST_FILE}", dataPath));
+ Files.toString(DrillFileUtils.getResourceAsFile(planPath), Charsets.UTF_8).replace("#{TEST_FILE}", dataPath));
RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());
|