Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4DDC1200D48 for ; Wed, 15 Nov 2017 02:46:54 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 4C466160C07; Wed, 15 Nov 2017 01:46:54 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 16809160C14 for ; Wed, 15 Nov 2017 02:46:51 +0100 (CET) Received: (qmail 53458 invoked by uid 500); 15 Nov 2017 01:46:50 -0000 Mailing-List: contact commits-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: commits@drill.apache.org Delivered-To: mailing list commits@drill.apache.org Received: (qmail 52724 invoked by uid 99); 15 Nov 2017 01:46:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Nov 2017 01:46:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3CBCFF5E4A; Wed, 15 Nov 2017 01:46:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: progers@apache.org To: commits@drill.apache.org Date: Wed, 15 Nov 2017 01:47:04 -0000 Message-Id: <72a886eb189543378576cced702c345b@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [18/22] drill git commit: DRILL-5783, DRILL-5841, DRILL-5894: Rationalize test temp directories archived-at: Wed, 15 Nov 2017 01:46:54 -0000 http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/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 0fafe53..bcfe8f3 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 @@ -17,32 +17,38 @@ */ package org.apache.drill; -import static org.apache.drill.TestBuilder.listOf; +import static org.apache.drill.test.TestBuilder.listOf; import static org.junit.Assert.assertEquals; import java.math.BigDecimal; +import java.nio.file.Paths; import org.apache.drill.categories.OperatorTest; import org.apache.drill.categories.PlannerTest; import org.apache.drill.categories.SqlFunctionTest; import org.apache.drill.categories.UnlikelyTest; import org.apache.drill.common.types.TypeProtos; -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.ExecConstants; +import org.apache.drill.test.BaseTestQuery; +import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; @Category({SqlFunctionTest.class, OperatorTest.class, PlannerTest.class}) public class TestExampleQueries extends BaseTestQuery { -// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestExampleQueries.class); + @BeforeClass + public static void setupTestFiles() { + dirTestWatcher.copyResourceToRoot(Paths.get("tpchmulti")); + dirTestWatcher.copyResourceToRoot(Paths.get("store","text")); + } @Test // see DRILL-2328 @Category(UnlikelyTest.class) public void testConcatOnNull() throws Exception { try { - test("use dfs_test.tmp"); + test("use dfs.tmp"); test("create view concatNull as (select * from cp.`customer.json` where customer_id < 5);"); // Test Left Null @@ -131,15 +137,15 @@ public class TestExampleQueries extends BaseTestQuery { @Test // see DRILL-985 public void testViewFileName() throws Exception { - test("use dfs_test.tmp"); + test("use dfs.tmp"); test("create view nation_view_testexamplequeries as select * from cp.`tpch/nation.parquet`;"); - test("select * from dfs_test.tmp.`nation_view_testexamplequeries.view.drill`"); + test("select * from dfs.tmp.`nation_view_testexamplequeries.view.drill`"); test("drop view nation_view_testexamplequeries"); } @Test public void testTextInClasspathStorage() throws Exception { - test("select * from cp.`/store/text/classpath_storage_csv_test.csv`"); + test("select * from cp.`store/text/classpath_storage_csv_test.csv`"); } @Test @@ -207,11 +213,9 @@ public class TestExampleQueries extends BaseTestQuery { @Test public void testPushExpInJoinConditionLeftJoin() throws Exception { - test("select a.n_nationkey, b.r_regionkey from cp.`tpch/nation.parquet` a left join cp.`tpch/region.parquet` b " + "" + - " on a.n_regionkey +100 = b.r_regionkey +200 " + // expressions in both sides of equal join filter - // " and (substr(a.n_name,1,3)= 'L1' or substr(a.n_name,2,2) = 'L2') " + // left filter - " and (substr(b.r_name,1,3)= 'R1' or substr(b.r_name,2,2) = 'R2') "); // right filter - // " and (substr(a.n_name,2,3)= 'L3' or substr(b.r_name,3,2) = 'R3');"); // non-equal join filter + test("select a.n_nationkey, b.r_regionkey from cp.`tpch/nation.parquet` a left join cp.`tpch/region.parquet` b " + + " on a.n_regionkey +100 = b.r_regionkey +200 " + // expressions in both sides of equal join filter // left filter + " and (substr(b.r_name,1,3)= 'R1' or substr(b.r_name,2,2) = 'R2') "); // right filter // non-equal join filter } @Test @@ -219,8 +223,6 @@ public class TestExampleQueries extends BaseTestQuery { test("select a.n_nationkey, b.r_regionkey from cp.`tpch/nation.parquet` a right join cp.`tpch/region.parquet` b " + "" + " on a.n_regionkey +100 = b.r_regionkey +200 " + // expressions in both sides of equal join filter " and (substr(a.n_name,1,3)= 'L1' or substr(a.n_name,2,2) = 'L2') "); // left filter - // " and (substr(b.r_name,1,3)= 'R1' or substr(b.r_name,2,2) = 'R2') " + // right filter - // " and (substr(a.n_name,2,3)= 'L3' or substr(b.r_name,3,2) = 'R3');"); // non-equal join filter } @Test @@ -273,25 +275,19 @@ public class TestExampleQueries extends BaseTestQuery { @Test public void testText() throws Exception { - String root = FileUtils.getResourceAsFile("/store/text/data/regions.csv").toURI().toString(); - String query = String.format("select * from dfs_test.`%s`", root); - test(query); + test("select * from cp.`store/text/data/regions.csv`"); } @Test public void testFilterOnArrayTypes() throws Exception { - String root = FileUtils.getResourceAsFile("/store/text/data/regions.csv").toURI().toString(); - String query = String.format("select columns[0] from dfs_test.`%s` " + - " where cast(columns[0] as int) > 1 and cast(columns[1] as varchar(20))='ASIA'", root); - test(query); + test("select columns[0] from cp.`store/text/data/regions.csv` " + + " where cast(columns[0] as int) > 1 and cast(columns[1] as varchar(20))='ASIA'"); } @Test @Ignore("DRILL-3774") public void testTextPartitions() throws Exception { - String root = FileUtils.getResourceAsFile("/store/text/data/").toURI().toString(); - String query = String.format("select * from dfs_test.`%s`", root); - test(query); + test("select * from cp.`store/text/data/`"); } @Test @@ -381,43 +377,33 @@ public class TestExampleQueries extends BaseTestQuery { @Test public void testTextJoin() throws Exception { - String root = FileUtils.getResourceAsFile("/store/text/data/nations.csv").toURI().toString(); - String root1 = FileUtils.getResourceAsFile("/store/text/data/regions.csv").toURI().toString(); - String query = String.format("select t1.columns[1] from dfs_test.`%s` t1, dfs_test.`%s` t2 where t1.columns[0] = t2.columns[0]", root, root1); - test(query); + test("select t1.columns[1] from cp.`store/text/data/nations.csv` t1, cp.`store/text/data/regions.csv` t2 where t1.columns[0] = t2.columns[0]"); } @Test // DRILL-811 public void testDRILL_811View() throws Exception { - test("use dfs_test.tmp"); + test("use dfs.tmp"); test("create view nation_view_testexamplequeries as select * from cp.`tpch/nation.parquet`;"); - test("select n.n_nationkey, n.n_name, n.n_regionkey from nation_view_testexamplequeries n where n.n_nationkey > 8 order by n.n_regionkey"); - test("select n.n_regionkey, count(*) as cnt from nation_view_testexamplequeries n where n.n_nationkey > 8 group by n.n_regionkey order by n.n_regionkey"); - test("drop view nation_view_testexamplequeries "); } @Test // DRILL-811 public void testDRILL_811ViewJoin() throws Exception { - test("use dfs_test.tmp"); + test("use dfs.tmp"); test("create view nation_view_testexamplequeries as select * from cp.`tpch/nation.parquet`;"); test("create view region_view_testexamplequeries as select * from cp.`tpch/region.parquet`;"); - test("select n.n_nationkey, n.n_regionkey, r.r_name from region_view_testexamplequeries r , nation_view_testexamplequeries n where r.r_regionkey = n.n_regionkey "); - test("select n.n_regionkey, count(*) as cnt from region_view_testexamplequeries r , nation_view_testexamplequeries n where r.r_regionkey = n.n_regionkey and n.n_nationkey > 8 group by n.n_regionkey order by n.n_regionkey"); - test("select n.n_regionkey, count(*) as cnt from region_view_testexamplequeries r join nation_view_testexamplequeries n on r.r_regionkey = n.n_regionkey and n.n_nationkey > 8 group by n.n_regionkey order by n.n_regionkey"); - test("drop view region_view_testexamplequeries "); test("drop view nation_view_testexamplequeries "); } @Test // DRILL-811 public void testDRILL_811Json() throws Exception { - test("use dfs_test.tmp"); + test("use dfs.tmp"); test("create view region_view_testexamplequeries as select * from cp.`region.json`;"); test("select sales_city, sales_region from region_view_testexamplequeries where region_id > 50 order by sales_country; "); test("drop view region_view_testexamplequeries "); @@ -435,7 +421,7 @@ public class TestExampleQueries extends BaseTestQuery { test("select t1.full_name from cp.`employee.json` t1, cp.`department.json` t2 where cast(t1.department_id as double) = t2.department_id and cast(t1.position_id as bigint) = t2.department_id"); // See DRILL-3995. Re-enable this once fixed. -// test("select t1.full_name from cp.`employee.json` t1, cp.`department.json` t2 where t1.department_id = t2.department_id and t1.position_id = t2.department_id"); + // test("select t1.full_name from cp.`employee.json` t1, cp.`department.json` t2 where t1.department_id = t2.department_id and t1.position_id = t2.department_id"); } @Test @@ -580,8 +566,8 @@ public class TestExampleQueries extends BaseTestQuery { expectedRecordCount, actualRecordCount), expectedRecordCount, actualRecordCount); // source is CSV - String root = FileUtils.getResourceAsFile("/store/text/data/regions.csv").toURI().toString(); - String query = String.format("select rid, x.name from (select columns[0] as RID, columns[1] as NAME from dfs_test.`%s`) X where X.rid = 2", root); + String root = DrillFileUtils.getResourceAsFile("/store/text/data/regions.csv").toURI().toString(); + String query = String.format("select rid, x.name from (select columns[0] as RID, columns[1] as NAME from dfs.`%s`) X where X.rid = 2", root); actualRecordCount = testSql(query); expectedRecordCount = 1; assertEquals(String.format("Received unexpected number of rows in output: expected=%d, received=%s", @@ -668,10 +654,7 @@ public class TestExampleQueries extends BaseTestQuery { @Test public void testExchangeRemoveForJoinPlan() throws Exception { - final String WORKING_PATH = TestTools.getWorkingPath(); - final String TEST_RES_PATH = WORKING_PATH + "/src/test/resources"; - - String sql = String.format("select t2.n_nationkey from dfs_test.`%s/tpchmulti/region` t1 join dfs_test.`%s/tpchmulti/nation` t2 on t2.n_regionkey = t1.r_regionkey", TEST_RES_PATH, TEST_RES_PATH); + String sql = "select t2.n_nationkey from dfs.`tpchmulti/region` t1 join dfs.`tpchmulti/nation` t2 on t2.n_regionkey = t1.r_regionkey"; testBuilder() .unOrdered() @@ -679,18 +662,16 @@ public class TestExampleQueries extends BaseTestQuery { .sqlQuery(sql) .optionSettingQueriesForBaseline("alter session set `planner.slice_target` = 100000; alter session set `planner.join.row_count_estimate_factor` = 1.0") // Use default option setting. .sqlBaselineQuery(sql) - .build().run(); - + .build() + .run(); } @Test //DRILL-2163 public void testNestedTypesPastJoinReportsValidResult() throws Exception { - final String query = "select t1.uid, t1.events, t1.events[0].evnt_id as event_id, t2.transactions, " + - "t2.transactions[0] as trans, t1.odd, t2.even from cp.`project/complex/a.json` t1, " + - "cp.`project/complex/b.json` t2 where t1.uid = t2.uid"; - testBuilder() - .sqlQuery(query) + .sqlQuery("select t1.uid, t1.events, t1.events[0].evnt_id as event_id, t2.transactions, " + + "t2.transactions[0] as trans, t1.odd, t2.even from cp.`project/complex/a.json` t1, " + + "cp.`project/complex/b.json` t2 where t1.uid = t2.uid") .ordered() .jsonBaselineFile("project/complex/drill-2163-result.json") .build() @@ -700,13 +681,11 @@ public class TestExampleQueries extends BaseTestQuery { @Test @Category(UnlikelyTest.class) public void testSimilar() throws Exception { - String query = "select n_nationkey " + - "from cp.`tpch/nation.parquet` " + - "where n_name similar to 'CHINA' " + - "order by n_regionkey"; - testBuilder() - .sqlQuery(query) + .sqlQuery("select n_nationkey " + + "from cp.`tpch/nation.parquet` " + + "where n_name similar to 'CHINA' " + + "order by n_regionkey") .unOrdered() .optionSettingQueriesForTestQuery("alter session set `planner.slice_target` = 1") .baselineColumns("n_nationkey") @@ -723,7 +702,7 @@ public class TestExampleQueries extends BaseTestQuery { "select cast(r_regionkey as BIGINT) BIGINT_col, cast(r_regionkey as DECIMAL) bigint_col \n" + "FROM cp.`tpch/region.parquet`;\n"; - test("USE dfs_test.tmp"); + test("USE dfs.tmp"); test(creatTable); testBuilder() @@ -763,14 +742,10 @@ public class TestExampleQueries extends BaseTestQuery { @Test // DRILL-2094 public void testOrderbyArrayElement() throws Exception { - String root = FileUtils.getResourceAsFile("/store/json/orderByArrayElement.json").toURI().toString(); - - String query = String.format("select t.id, t.list[0] as SortingElem " + - "from dfs_test.`%s` t " + - "order by t.list[0]", root); - testBuilder() - .sqlQuery(query) + .sqlQuery("select t.id, t.list[0] as SortingElem " + + "from cp.`store/json/orderByArrayElement.json` t " + + "order by t.list[0]") .ordered() .baselineColumns("id", "SortingElem") .baselineValues((long) 1, (long) 1) @@ -783,12 +758,10 @@ public class TestExampleQueries extends BaseTestQuery { @Test // DRILL-2479 public void testCorrelatedExistsWithInSubq() throws Exception { - String query = "select count(*) as cnt from cp.`tpch/lineitem.parquet` l where exists " - + " (select ps.ps_suppkey from cp.`tpch/partsupp.parquet` ps where ps.ps_suppkey = l.l_suppkey and ps.ps_partkey " - + " in (select p.p_partkey from cp.`tpch/part.parquet` p where p.p_type like '%NICKEL'))"; - testBuilder() - .sqlQuery(query) + .sqlQuery("select count(*) as cnt from cp.`tpch/lineitem.parquet` l where exists " + + " (select ps.ps_suppkey from cp.`tpch/partsupp.parquet` ps where ps.ps_suppkey = l.l_suppkey and ps.ps_partkey " + + " in (select p.p_partkey from cp.`tpch/part.parquet` p where p.p_type like '%NICKEL'))") .unOrdered() .baselineColumns("cnt") .baselineValues(60175l) @@ -797,15 +770,11 @@ public class TestExampleQueries extends BaseTestQuery { @Test // DRILL-2094 public void testOrderbyArrayElementInSubquery() throws Exception { - String root = FileUtils.getResourceAsFile("/store/json/orderByArrayElement.json").toURI().toString(); - - String query = String.format("select s.id from \n" + - "(select id \n" + - "from dfs_test.`%s` \n" + - "order by list[0]) s", root); - testBuilder() - .sqlQuery(query) + .sqlQuery("select s.id from " + + "(select id " + + "from cp.`store/json/orderByArrayElement.json` " + + "order by list[0]) s") .ordered() .baselineColumns("id") .baselineValues((long) 1) @@ -818,17 +787,16 @@ public class TestExampleQueries extends BaseTestQuery { @Test // DRILL-1978 public void testCTASOrderByCoumnNotInSelectClause() throws Exception { - String root = FileUtils.getResourceAsFile("/store/text/data/regions.csv").toURI().toString(); String queryCTAS1 = "CREATE TABLE TestExampleQueries_testCTASOrderByCoumnNotInSelectClause1 as " + "select r_name from cp.`tpch/region.parquet` order by r_regionkey;"; - String queryCTAS2 = String.format("CREATE TABLE TestExampleQueries_testCTASOrderByCoumnNotInSelectClause2 as " + - "SELECT columns[1] as col FROM dfs_test.`%s` ORDER BY cast(columns[0] as double)", root); + String queryCTAS2 = "CREATE TABLE TestExampleQueries_testCTASOrderByCoumnNotInSelectClause2 as " + + "SELECT columns[1] as col FROM cp.`store/text/data/regions.csv` ORDER BY cast(columns[0] as double)"; String query1 = "select * from TestExampleQueries_testCTASOrderByCoumnNotInSelectClause1"; String query2 = "select * from TestExampleQueries_testCTASOrderByCoumnNotInSelectClause2"; - test("use dfs_test.tmp"); + test("use dfs.tmp"); test(queryCTAS1); test(queryCTAS2); @@ -858,12 +826,11 @@ public class TestExampleQueries extends BaseTestQuery { @Test // DRILL-2221 public void createJsonWithEmptyList() throws Exception { - final String file = FileUtils.getResourceAsFile("/store/json/record_with_empty_list.json").toURI().toString(); final String tableName = "jsonWithEmptyList"; - test("USE dfs_test.tmp"); + test("USE dfs.tmp"); test("ALTER SESSION SET `store.format`='json'"); - test(String.format("CREATE TABLE %s AS SELECT * FROM `%s`", tableName, file)); - test(String.format("SELECT COUNT(*) FROM %s", tableName)); + test("CREATE TABLE %s AS SELECT * FROM cp.`store/json/record_with_empty_list.json`", tableName); + test("SELECT COUNT(*) FROM %s", tableName); test("ALTER SESSION SET `store.format`='parquet'"); } @@ -986,15 +953,11 @@ public class TestExampleQueries extends BaseTestQuery { @Test //DRILL-2953 public void testGbAndObDifferentExp() throws Exception { - String root = FileUtils.getResourceAsFile("/store/text/data/nations.csv").toURI().toString(); - String query = String.format( - "select cast(columns[0] as int) as nation_key " + - " from dfs_test.`%s` " + - " group by columns[0] " + - " order by cast(columns[0] as int)", root); - testBuilder() - .sqlQuery(query) + .sqlQuery("select cast(columns[0] as int) as nation_key " + + " from cp.`store/text/data/nations.csv` " + + " group by columns[0] " + + " order by cast(columns[0] as int)") .ordered() .csvBaselineFile("testframework/testExampleQueries/testGroupByStarSchemaless.tsv") .baselineTypes(TypeProtos.MinorType.INT) @@ -1002,14 +965,11 @@ public class TestExampleQueries extends BaseTestQuery { .build() .run(); - String query2 = String.format( - "select cast(columns[0] as int) as nation_key " + - " from dfs_test.`%s` " + - " group by cast(columns[0] as int) " + - " order by cast(columns[0] as int)", root); - testBuilder() - .sqlQuery(query2) + .sqlQuery("select cast(columns[0] as int) as nation_key " + + " from cp.`store/text/data/nations.csv` " + + " group by cast(columns[0] as int) " + + " order by cast(columns[0] as int)") .ordered() .csvBaselineFile("testframework/testExampleQueries/testGroupByStarSchemaless.tsv") .baselineTypes(TypeProtos.MinorType.INT) @@ -1040,7 +1000,6 @@ public class TestExampleQueries extends BaseTestQuery { "ALTER SESSION SET `planner.disable_exchanges` = true") .build() .run(); - } @Test @@ -1057,18 +1016,18 @@ public class TestExampleQueries extends BaseTestQuery { @Test @Ignore public void testPartitionCTAS() throws Exception { - test("use dfs_test.tmp; " + + test("use dfs.tmp; " + "create table mytable1 partition by (r_regionkey, r_comment) as select r_regionkey, r_name, r_comment from cp.`tpch/region.parquet`"); - test("use dfs_test.tmp; " + + test("use dfs.tmp; " + "create table mytable2 partition by (r_regionkey, r_comment) as select * from cp.`tpch/region.parquet` where r_name = 'abc' "); - test("use dfs_test.tmp; " + + test("use dfs.tmp; " + "create table mytable3 partition by (r_regionkey, n_nationkey) as " + " select r.r_regionkey, r.r_name, n.n_nationkey, n.n_name from cp.`tpch/nation.parquet` n, cp.`tpch/region.parquet` r " + " where n.n_regionkey = r.r_regionkey"); - test("use dfs_test.tmp; " + + test("use dfs.tmp; " + "create table mytable4 partition by (r_regionkey, r_comment) as " + " select r.* from cp.`tpch/nation.parquet` n, cp.`tpch/region.parquet` r " + " where n.n_regionkey = r.r_regionkey"); @@ -1115,26 +1074,18 @@ public class TestExampleQueries extends BaseTestQuery { @Test // see DRILL-3557 @Category(UnlikelyTest.class) public void testEmptyCSVinDirectory() throws Exception { - final String root = FileUtils.getResourceAsFile("/store/text/directoryWithEmpyCSV").toURI().toString(); - final String toFile = FileUtils.getResourceAsFile("/store/text/directoryWithEmpyCSV/empty.csv").toURI().toString(); - - String query1 = String.format("explain plan for select * from dfs_test.`%s`", root); - String query2 = String.format("explain plan for select * from dfs_test.`%s`", toFile); - - test(query1); - test(query2); + test("explain plan for select * from dfs.`store/text/directoryWithEmpyCSV`"); + test("explain plan for select * from cp.`store/text/directoryWithEmpyCSV/empty.csv`"); } @Test @Category(UnlikelyTest.class) public void testNegativeExtractOperator() throws Exception { - String query = "select -EXTRACT(DAY FROM birth_date) as col \n" + - "from cp.`employee.json` \n" + - "order by col \n" + - "limit 5"; - testBuilder() - .sqlQuery(query) + .sqlQuery("select -EXTRACT(DAY FROM birth_date) as col \n" + + "from cp.`employee.json` \n" + + "order by col \n" + + "limit 5") .ordered() .baselineColumns("col") .baselineValues(-27l) http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java b/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java index a302b71..1b551ec 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java +++ b/exec/java-exec/src/test/java/org/apache/drill/TestFrameworkTest.java @@ -17,8 +17,8 @@ ******************************************************************************/ package org.apache.drill; -import static org.apache.drill.TestBuilder.listOf; -import static org.apache.drill.TestBuilder.mapOf; +import static org.apache.drill.test.TestBuilder.listOf; +import static org.apache.drill.test.TestBuilder.mapOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -34,6 +34,8 @@ import org.apache.drill.common.expression.SchemaPath; import org.apache.drill.common.types.TypeProtos; import org.apache.drill.common.types.Types; import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.test.BaseTestQuery; +import org.apache.drill.test.TestBuilder; import org.hamcrest.CoreMatchers; import org.junit.Test; @@ -43,7 +45,7 @@ import com.google.common.collect.Lists; // currently using it with the assumption that the csv and json readers are well tested, and handling diverse // types in the test framework would require doing some redundant work to enable casting outside of Drill or // some better tooling to generate parquet files that have all of the parquet types -public class TestFrameworkTest extends BaseTestQuery{ +public class TestFrameworkTest extends BaseTestQuery { private static String CSV_COLS = " cast(columns[0] as bigint) employee_id, columns[1] as first_name, columns[2] as last_name "; @@ -171,7 +173,7 @@ public class TestFrameworkTest extends BaseTestQuery{ @Test public void testMapOrdering() throws Exception { testBuilder() - .sqlQuery("select * from cp.`/testframework/map_reordering.json`") + .sqlQuery("select * from cp.`testframework/map_reordering.json`") .unOrdered() .jsonBaselineFile("testframework/map_reordering2.json") .build().run(); @@ -203,7 +205,7 @@ public class TestFrameworkTest extends BaseTestQuery{ @Test public void testBaselineValsVerificationWithComplexAndNulls() throws Exception { testBuilder() - .sqlQuery("select * from cp.`/jsoninput/input2.json` limit 1") + .sqlQuery("select * from cp.`jsoninput/input2.json` limit 1") .ordered() .baselineColumns("integer", "float", "x", "z", "l", "rl") .baselineValues(2010l, @@ -241,7 +243,7 @@ public class TestFrameworkTest extends BaseTestQuery{ public void testCSVVerification_extra_records_fails() throws Exception { try { testBuilder() - .sqlQuery("select " + CSV_COLS + " from cp.`testframework/small_test_data_extra.tsv`") + .sqlQuery("select %s from cp.`testframework/small_test_data_extra.tsv`", CSV_COLS) .ordered() .csvBaselineFile("testframework/small_test_data.tsv") .baselineTypes(TypeProtos.MinorType.BIGINT, TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.VARCHAR) http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsQuery.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsQuery.java b/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsQuery.java index 1e8fc44..0750d61 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsQuery.java +++ b/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsQuery.java @@ -19,6 +19,7 @@ package org.apache.drill; import org.apache.drill.categories.SqlFunctionTest; import org.apache.drill.exec.planner.physical.PlannerSettings; +import org.apache.drill.test.BaseTestQuery; import org.joda.time.DateTime; import org.junit.AfterClass; import org.junit.BeforeClass; http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsWithTypeExpoQueries.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsWithTypeExpoQueries.java b/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsWithTypeExpoQueries.java index e73fd41..88558ae 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsWithTypeExpoQueries.java +++ b/exec/java-exec/src/test/java/org/apache/drill/TestFunctionsWithTypeExpoQueries.java @@ -22,14 +22,21 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.drill.categories.SqlFunctionTest; 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.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(SqlFunctionTest.class) public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { + @BeforeClass + public static void setupFiles() { + dirTestWatcher.copyResourceToRoot(Paths.get("typeExposure")); + } + @Test public void testConcatWithMoreThanTwoArgs() throws Exception { final String query = "select concat(r_name, r_name, r_name, 'f') as col \n" + @@ -52,24 +59,20 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testRow_NumberInView() throws Exception { try { - test("use dfs_test.tmp;"); - final String view1 = - "create view TestFunctionsWithTypeExpoQueries_testViewShield1 as \n" + - "select rnum, position_id, " + - " ntile(4) over(order by position_id) " + - " from (select position_id, row_number() " + - " over(order by position_id) as rnum " + - " from cp.`employee.json`)"; - - final String view2 = - "create view TestFunctionsWithTypeExpoQueries_testViewShield2 as \n" + - "select row_number() over(order by position_id) as rnum, " + - " position_id, " + - " ntile(4) over(order by position_id) " + - " from cp.`employee.json`"; - - test(view1); - test(view2); + test("use dfs.tmp;"); + test( + "create view TestFunctionsWithTypeExpoQueries_testViewShield1 as \n" + + "select rnum, position_id, " + + " ntile(4) over(order by position_id) " + + " from (select position_id, row_number() " + + " over(order by position_id) as rnum " + + " from cp.`employee.json`)"); + test( + "create view TestFunctionsWithTypeExpoQueries_testViewShield2 as \n" + + "select row_number() over(order by position_id) as rnum, " + + " position_id, " + + " ntile(4) over(order by position_id) " + + " from cp.`employee.json`"); testBuilder() .sqlQuery("select * from TestFunctionsWithTypeExpoQueries_testViewShield1") .ordered() @@ -253,10 +256,9 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testMetaDataExposeType() throws Exception { - final String root = FileUtils.getResourceAsFile("/typeExposure/metadata_caching").toURI().toString(); - final String query = String.format("select count(*) as col \n" + - "from dfs_test.`%s` \n" + - "where concat(a, 'asdf') = 'asdf'", root); + final String query = "select count(*) as col " + + "from dfs.`typeExposure/metadata_caching` " + + "where concat(a, 'asdf') = 'asdf'"; // Validate the plan final String[] expectedPlan = {"Scan.*a.parquet.*numFiles = 1"}; @@ -275,8 +277,8 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testDate_Part() throws Exception { - final String query = "select date_part('year', date '2008-2-23') as col \n" + - "from cp.`tpch/region.parquet` \n" + + final String query = "select date_part('year', date '2008-2-23') as col " + + "from cp.`tpch/region.parquet` " + "limit 0"; List> expectedSchema = Lists.newArrayList(); @@ -295,7 +297,7 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testNegativeByInterpreter() throws Exception { - final String query = "select * from cp.`tpch/region.parquet` \n" + + final String query = "select * from cp.`tpch/region.parquet` " + "where r_regionkey = negative(-1)"; // Validate the plan @@ -306,10 +308,10 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testSumRequiredType() throws Exception { - final String query = "SELECT \n" + - "SUM(CASE WHEN (CAST(n_regionkey AS INT) = 1) THEN 1 ELSE 0 END) AS col \n" + - "FROM cp.`tpch/nation.parquet` \n" + - "GROUP BY CAST(n_regionkey AS INT) \n" + + final String query = "SELECT " + + "SUM(CASE WHEN (CAST(n_regionkey AS INT) = 1) THEN 1 ELSE 0 END) AS col " + + "FROM cp.`tpch/nation.parquet` " + + "GROUP BY CAST(n_regionkey AS INT) " + "limit 0"; List> expectedSchema = Lists.newArrayList(); @@ -328,8 +330,8 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testSQRTDecimalLiteral() throws Exception { - final String query = "SELECT sqrt(5.1) as col \n" + - "from cp.`tpch/nation.parquet` \n" + + final String query = "SELECT sqrt(5.1) as col " + + "from cp.`tpch/nation.parquet` " + "limit 0"; List> expectedSchema = Lists.newArrayList(); @@ -348,8 +350,8 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testSQRTIntegerLiteral() throws Exception { - final String query = "SELECT sqrt(4) as col \n" + - "from cp.`tpch/nation.parquet` \n" + + final String query = "SELECT sqrt(4) as col " + + "from cp.`tpch/nation.parquet` " + "limit 0"; List> expectedSchema = Lists.newArrayList(); @@ -368,8 +370,8 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testTimestampDiff() throws Exception { - final String query = "select to_timestamp('2014-02-13 00:30:30','YYYY-MM-dd HH:mm:ss') - to_timestamp('2014-02-13 00:30:30','YYYY-MM-dd HH:mm:ss') as col \n" + - "from cp.`tpch/region.parquet` \n" + + final String query = "select to_timestamp('2014-02-13 00:30:30','YYYY-MM-dd HH:mm:ss') - to_timestamp('2014-02-13 00:30:30','YYYY-MM-dd HH:mm:ss') as col " + + "from cp.`tpch/region.parquet` " + "limit 0"; final List> expectedSchema = Lists.newArrayList(); @@ -388,9 +390,9 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testEqualBetweenIntervalAndTimestampDiff() throws Exception { - final String query = "select to_timestamp('2016-11-02 10:00:00','YYYY-MM-dd HH:mm:ss') + interval '10-11' year to month as col \n" + - "from cp.`tpch/region.parquet` \n" + - "where (to_timestamp('2016-11-02 10:00:00','YYYY-MM-dd HH:mm:ss') - to_timestamp('2016-01-01 10:00:00','YYYY-MM-dd HH:mm:ss') < interval '5 10:00:00' day to second) \n" + + final String query = "select to_timestamp('2016-11-02 10:00:00','YYYY-MM-dd HH:mm:ss') + interval '10-11' year to month as col " + + "from cp.`tpch/region.parquet` " + + "where (to_timestamp('2016-11-02 10:00:00','YYYY-MM-dd HH:mm:ss') - to_timestamp('2016-01-01 10:00:00','YYYY-MM-dd HH:mm:ss') < interval '5 10:00:00' day to second) " + "limit 0"; final List> expectedSchema = Lists.newArrayList(); @@ -409,11 +411,11 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testAvgAndSUM() throws Exception { - final String query = "SELECT AVG(cast(r_regionkey as float)) AS `col1`, \n" + - "SUM(cast(r_regionkey as float)) AS `col2`, \n" + - "SUM(1) AS `col3` \n" + - "FROM cp.`tpch/region.parquet` \n" + - "GROUP BY CAST(r_regionkey AS INTEGER) \n" + + final String query = "SELECT AVG(cast(r_regionkey as float)) AS `col1`, " + + "SUM(cast(r_regionkey as float)) AS `col2`, " + + "SUM(1) AS `col3` " + + "FROM cp.`tpch/region.parquet` " + + "GROUP BY CAST(r_regionkey AS INTEGER) " + "LIMIT 0"; final List> expectedSchema = Lists.newArrayList(); @@ -445,10 +447,10 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testAvgCountStar() throws Exception { - final String query = "select avg(distinct cast(r_regionkey as bigint)) + avg(cast(r_regionkey as integer)) as col1, \n" + - "sum(distinct cast(r_regionkey as bigint)) + 100 as col2, count(*) as col3 \n" + - "from cp.`tpch/region.parquet` alltypes_v \n" + - "where cast(r_regionkey as bigint) = 100000000000000000 \n" + + final String query = "select avg(distinct cast(r_regionkey as bigint)) + avg(cast(r_regionkey as integer)) as col1, " + + "sum(distinct cast(r_regionkey as bigint)) + 100 as col2, count(*) as col3 " + + "from cp.`tpch/region.parquet` alltypes_v " + + "where cast(r_regionkey as bigint) = 100000000000000000 " + "limit 0"; final List> expectedSchema = Lists.newArrayList(); @@ -479,15 +481,15 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testUDFInGroupBy() throws Exception { - final String query = "select count(*) as col1, substr(lower(UPPER(cast(t3.full_name as varchar(100)))), 5, 2) as col2, \n" + - "char_length(substr(lower(UPPER(cast(t3.full_name as varchar(100)))), 5, 2)) as col3 \n" + - "from cp.`tpch/region.parquet` t1 \n" + - "left outer join cp.`tpch/nation.parquet` t2 on cast(t1.r_regionkey as Integer) = cast(t2.n_nationkey as Integer) \n" + - "left outer join cp.`employee.json` t3 on cast(t1.r_regionkey as Integer) = cast(t3.employee_id as Integer) \n" + - "group by substr(lower(UPPER(cast(t3.full_name as varchar(100)))), 5, 2), \n" + - "char_length(substr(lower(UPPER(cast(t3.full_name as varchar(100)))), 5, 2)) \n" + - "order by substr(lower(UPPER(cast(t3.full_name as varchar(100)))), 5, 2),\n" + - "char_length(substr(lower(UPPER(cast(t3.full_name as varchar(100)))), 5, 2)) \n" + + final String query = "select count(*) as col1, substr(lower(UPPER(cast(t3.full_name as varchar(100)))), 5, 2) as col2, " + + "char_length(substr(lower(UPPER(cast(t3.full_name as varchar(100)))), 5, 2)) as col3 " + + "from cp.`tpch/region.parquet` t1 " + + "left outer join cp.`tpch/nation.parquet` t2 on cast(t1.r_regionkey as Integer) = cast(t2.n_nationkey as Integer) " + + "left outer join cp.`employee.json` t3 on cast(t1.r_regionkey as Integer) = cast(t3.employee_id as Integer) " + + "group by substr(lower(UPPER(cast(t3.full_name as varchar(100)))), 5, 2), " + + "char_length(substr(lower(UPPER(cast(t3.full_name as varchar(100)))), 5, 2)) " + + "order by substr(lower(UPPER(cast(t3.full_name as varchar(100)))), 5, 2)," + + "char_length(substr(lower(UPPER(cast(t3.full_name as varchar(100)))), 5, 2)) " + "limit 0"; final List> expectedSchema = Lists.newArrayList(); @@ -518,12 +520,12 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testWindowSumAvg() throws Exception { - final String query = "with query as ( \n" + - "select sum(cast(employee_id as integer)) over w as col1, cast(avg(cast(employee_id as bigint)) over w as double precision) as col2, count(*) over w as col3 \n" + - "from cp.`tpch/region.parquet` \n" + - "window w as (partition by cast(full_name as varchar(10)) order by cast(full_name as varchar(10)) nulls first)) \n" + - "select * \n" + - "from query \n" + + final String query = "with query as ( " + + "select sum(cast(employee_id as integer)) over w as col1, cast(avg(cast(employee_id as bigint)) over w as double precision) as col2, count(*) over w as col3 " + + "from cp.`tpch/region.parquet` " + + "window w as (partition by cast(full_name as varchar(10)) order by cast(full_name as varchar(10)) nulls first)) " + + "select * " + + "from query " + "limit 0"; final List> expectedSchema = Lists.newArrayList(); @@ -554,24 +556,24 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testWindowRanking() throws Exception { - final String queryCUME_DIST = "select CUME_DIST() over(order by n_nationkey) as col \n" + - "from cp.`tpch/nation.parquet` \n" + + final String queryCUME_DIST = "select CUME_DIST() over(order by n_nationkey) as col " + + "from cp.`tpch/nation.parquet` " + "limit 0"; - final String queryDENSE_RANK = "select DENSE_RANK() over(order by n_nationkey) as col \n" + - "from cp.`tpch/nation.parquet` \n" + + final String queryDENSE_RANK = "select DENSE_RANK() over(order by n_nationkey) as col " + + "from cp.`tpch/nation.parquet` " + "limit 0"; - final String queryPERCENT_RANK = "select PERCENT_RANK() over(order by n_nationkey) as col \n" + - "from cp.`tpch/nation.parquet` \n" + + final String queryPERCENT_RANK = "select PERCENT_RANK() over(order by n_nationkey) as col " + + "from cp.`tpch/nation.parquet` " + "limit 0"; - final String queryRANK = "select RANK() over(order by n_nationkey) as col \n" + - "from cp.`tpch/nation.parquet` \n" + + final String queryRANK = "select RANK() over(order by n_nationkey) as col " + + "from cp.`tpch/nation.parquet` " + "limit 0"; - final String queryROW_NUMBER = "select ROW_NUMBER() over(order by n_nationkey) as col \n" + - "from cp.`tpch/nation.parquet` \n" + + final String queryROW_NUMBER = "select ROW_NUMBER() over(order by n_nationkey) as col " + + "from cp.`tpch/nation.parquet` " + "limit 0"; final TypeProtos.MajorType majorTypeDouble = TypeProtos.MajorType.newBuilder() @@ -632,8 +634,8 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testWindowNTILE() throws Exception { - final String query = "select ntile(1) over(order by position_id) as col \n" + - "from cp.`employee.json` \n" + + final String query = "select ntile(1) over(order by position_id) as col " + + "from cp.`employee.json` " + "limit 0"; final TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder() @@ -653,11 +655,11 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testLeadLag() throws Exception { - final String queryLEAD = "select lead(cast(n_nationkey as BigInt)) over(order by n_nationkey) as col \n" + - "from cp.`tpch/nation.parquet` \n" + + final String queryLEAD = "select lead(cast(n_nationkey as BigInt)) over(order by n_nationkey) as col " + + "from cp.`tpch/nation.parquet` " + "limit 0"; - final String queryLAG = "select lag(cast(n_nationkey as BigInt)) over(order by n_nationkey) as col \n" + - "from cp.`tpch/nation.parquet` \n" + + final String queryLAG = "select lag(cast(n_nationkey as BigInt)) over(order by n_nationkey) as col " + + "from cp.`tpch/nation.parquet` " + "limit 0"; final TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder() @@ -683,12 +685,12 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test public void testFirst_Last_Value() throws Exception { - final String queryFirst = "select first_value(cast(position_id as integer)) over(order by position_id) as col \n" + - "from cp.`employee.json` \n" + + final String queryFirst = "select first_value(cast(position_id as integer)) over(order by position_id) as col " + + "from cp.`employee.json` " + "limit 0"; - final String queryLast = "select first_value(cast(position_id as integer)) over(order by position_id) as col \n" + - "from cp.`employee.json` \n" + + final String queryLast = "select first_value(cast(position_id as integer)) over(order by position_id) as col " + + "from cp.`employee.json` " + "limit 0"; final TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder() @@ -714,8 +716,8 @@ public class TestFunctionsWithTypeExpoQueries extends BaseTestQuery { @Test // DRILL-4529 public void testWindowSumConstant() throws Exception { - final String query = "select sum(1) over w as col \n" + - "from cp.`tpch/region.parquet` \n" + + final String query = "select sum(1) over w as col " + + "from cp.`tpch/region.parquet` " + "window w as (partition by r_regionkey)"; final String[] expectedPlan = {"\\$SUM0"}; http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/TestInList.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestInList.java b/exec/java-exec/src/test/java/org/apache/drill/TestInList.java index 79dfa13..08f3d9a 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/TestInList.java +++ b/exec/java-exec/src/test/java/org/apache/drill/TestInList.java @@ -20,11 +20,12 @@ package org.apache.drill; import static org.junit.Assert.assertEquals; import org.apache.drill.categories.SqlTest; +import org.apache.drill.test.BaseTestQuery; import org.junit.Test; import org.junit.experimental.categories.Category; @Category(SqlTest.class) -public class TestInList extends BaseTestQuery{ +public class TestInList extends BaseTestQuery { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestInList.class); @Test http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/TestJoinNullable.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestJoinNullable.java b/exec/java-exec/src/test/java/org/apache/drill/TestJoinNullable.java index 690f793..89a9e9d 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/TestJoinNullable.java +++ b/exec/java-exec/src/test/java/org/apache/drill/TestJoinNullable.java @@ -20,29 +20,25 @@ package org.apache.drill; import static org.junit.Assert.assertEquals; import org.apache.drill.categories.OperatorTest; -import org.apache.drill.common.util.TestTools; +import org.apache.drill.test.BaseTestQuery; import org.junit.Test; import org.junit.experimental.categories.Category; @Category(OperatorTest.class) -public class TestJoinNullable extends BaseTestQuery{ +public class TestJoinNullable extends BaseTestQuery { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestJoinNullable.class); - static final String WORKING_PATH = TestTools.getWorkingPath(); - static final String TEST_RES_PATH = WORKING_PATH + "/src/test/resources"; - private static void enableJoin(boolean hj, boolean mj) throws Exception { - - test(String.format("alter session set `planner.enable_hashjoin` = %s", hj ? "true":"false")); - test(String.format("alter session set `planner.enable_mergejoin` = %s", mj ? "true":"false")); + test("alter session set `planner.enable_hashjoin` = %s", hj); + test("alter session set `planner.enable_mergejoin` = %s", mj); test("alter session set `planner.slice_target` = 1"); } /** InnerJoin on nullable cols, HashJoin */ @Test public void testHashInnerJoinOnNullableColumns() throws Exception { - String query = String.format("select t1.a1, t1.b1, t2.a2, t2.b2 from dfs_test.`%s/jsoninput/nullable1.json` t1, " + - " dfs_test.`%s/jsoninput/nullable2.json` t2 where t1.b1 = t2.b2", TEST_RES_PATH, TEST_RES_PATH); + String query = "select t1.a1, t1.b1, t2.a2, t2.b2 from cp.`jsoninput/nullable1.json` t1, " + + " cp.`jsoninput/nullable2.json` t2 where t1.b1 = t2.b2"; final int expectedRecordCount = 1; enableJoin(true, false); @@ -53,9 +49,9 @@ public class TestJoinNullable extends BaseTestQuery{ /** LeftOuterJoin on nullable cols, HashJoin */ @Test public void testHashLOJOnNullableColumns() throws Exception { - String query = String.format("select t1.a1, t1.b1, t2.a2, t2.b2 from dfs_test.`%s/jsoninput/nullable1.json` t1 " + - " left outer join dfs_test.`%s/jsoninput/nullable2.json` t2 " + - " on t1.b1 = t2.b2", TEST_RES_PATH, TEST_RES_PATH); + String query = "select t1.a1, t1.b1, t2.a2, t2.b2 from cp.`jsoninput/nullable1.json` t1 " + + " left outer join cp.`jsoninput/nullable2.json` t2 " + + " on t1.b1 = t2.b2"; final int expectedRecordCount = 2; @@ -67,9 +63,9 @@ public class TestJoinNullable extends BaseTestQuery{ /** RightOuterJoin on nullable cols, HashJoin */ @Test public void testHashROJOnNullableColumns() throws Exception { - String query = String.format("select t1.a1, t1.b1, t2.a2, t2.b2 from dfs_test.`%s/jsoninput/nullable1.json` t1 " + - " right outer join dfs_test.`%s/jsoninput/nullable2.json` t2 " + - " on t1.b1 = t2.b2", TEST_RES_PATH, TEST_RES_PATH); + String query = "select t1.a1, t1.b1, t2.a2, t2.b2 from cp.`jsoninput/nullable1.json` t1 " + + " right outer join cp.`jsoninput/nullable2.json` t2 " + + " on t1.b1 = t2.b2"; final int expectedRecordCount = 4; @@ -81,9 +77,9 @@ public class TestJoinNullable extends BaseTestQuery{ /** FullOuterJoin on nullable cols, HashJoin */ @Test public void testHashFOJOnNullableColumns() throws Exception { - String query = String.format("select t1.a1, t1.b1, t2.a2, t2.b2 from dfs_test.`%s/jsoninput/nullable1.json` t1 " + - " full outer join dfs_test.`%s/jsoninput/nullable2.json` t2 " + - " on t1.b1 = t2.b2", TEST_RES_PATH, TEST_RES_PATH); + String query = "select t1.a1, t1.b1, t2.a2, t2.b2 from cp.`jsoninput/nullable1.json` t1 " + + " full outer join cp.`jsoninput/nullable2.json` t2 " + + " on t1.b1 = t2.b2"; final int expectedRecordCount = +5; @@ -96,11 +92,10 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeInnerJoinOnNullableColumns() throws Exception { String query = - String.format( "select t1.a1, t1.b1, t2.a2, t2.b2 " - + " from dfs_test.`%s/jsoninput/nullable1.json` t1, " - + " dfs_test.`%s/jsoninput/nullable2.json` t2 " - + " where t1.b1 = t2.b2", TEST_RES_PATH, TEST_RES_PATH); + + " from cp.`jsoninput/nullable1.json` t1, " + + " cp.`jsoninput/nullable2.json` t2 " + + " where t1.b1 = t2.b2"; final int expectedRecordCount = 1; enableJoin(false, true); @@ -111,9 +106,9 @@ public class TestJoinNullable extends BaseTestQuery{ /** LeftOuterJoin on nullable cols, MergeJoin */ @Test public void testMergeLOJNullable() throws Exception { - String query = String.format("select t1.a1, t1.b1, t2.a2, t2.b2 from dfs_test.`%s/jsoninput/nullable1.json` t1 " + - " left outer join dfs_test.`%s/jsoninput/nullable2.json` t2 " + - " on t1.b1 = t2.b2", TEST_RES_PATH, TEST_RES_PATH); + String query = "select t1.a1, t1.b1, t2.a2, t2.b2 from cp.`jsoninput/nullable1.json` t1 " + + " left outer join cp.`jsoninput/nullable2.json` t2 " + + " on t1.b1 = t2.b2"; final int expectedRecordCount = 2; @@ -125,9 +120,9 @@ public class TestJoinNullable extends BaseTestQuery{ /** RightOuterJoin on nullable cols, MergeJoin */ @Test public void testMergeROJOnNullableColumns() throws Exception { - String query = String.format("select t1.a1, t1.b1, t2.a2, t2.b2 from dfs_test.`%s/jsoninput/nullable1.json` t1 " + - " right outer join dfs_test.`%s/jsoninput/nullable2.json` t2 " + - " on t1.b1 = t2.b2", TEST_RES_PATH, TEST_RES_PATH); + String query = "select t1.a1, t1.b1, t2.a2, t2.b2 from cp.`jsoninput/nullable1.json` t1 " + + " right outer join cp.`jsoninput/nullable2.json` t2 " + + " on t1.b1 = t2.b2"; final int expectedRecordCount = 4; @@ -141,12 +136,10 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeLOJNullableNoOrderedInputs() throws Exception { String query = - String.format( "SELECT * " - + "FROM dfs_test.`%s/jsoninput/nullableOrdered1.json` t1 " - + " left outer join dfs_test.`%s/jsoninput/nullableOrdered2.json` t2 " - + " using ( key )", - TEST_RES_PATH, TEST_RES_PATH); + + "FROM cp.`jsoninput/nullableOrdered1.json` t1 " + + " left outer join cp.`jsoninput/nullableOrdered2.json` t2 " + + " using ( key )"; final int expectedRecordCount = 6; enableJoin(false, true); @@ -158,15 +151,13 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeLOJNullableOneOrderedInputAscNullsFirst() throws Exception { String query = - String.format( "SELECT * " - + "from dfs_test.`%s/jsoninput/nullableOrdered1.json` t1 " + + "from cp.`jsoninput/nullableOrdered1.json` t1 " + " LEFT OUTER JOIN " + " ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered2.json` t2 " + + " FROM cp.`jsoninput/nullableOrdered2.json` t2 " + " ORDER BY 1 ASC NULLS FIRST ) t2 " - + " USING ( key )", - TEST_RES_PATH, TEST_RES_PATH); + + " USING ( key )"; final int expectedRecordCount = 6; enableJoin(false, true); @@ -178,15 +169,13 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeLOJNullableOneOrderedInputAscNullsLast() throws Exception { String query = - String.format( "SELECT * " - + "FROM dfs_test.`%s/jsoninput/nullableOrdered1.json` t1 " + + "FROM cp.`jsoninput/nullableOrdered1.json` t1 " + " LEFT OUTER JOIN " + " ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered2.json` t2 " + + " FROM cp.`jsoninput/nullableOrdered2.json` t2 " + " ORDER BY 1 ASC NULLS LAST ) t2 " - + " USING ( key )", - TEST_RES_PATH, TEST_RES_PATH); + + " USING ( key )"; final int expectedRecordCount = 6; enableJoin(false, true); @@ -198,15 +187,13 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeLOJNullableOneOrderedInputDescNullsFirst() throws Exception { String query = - String.format( "SELECT * " - + "FROM dfs_test.`%s/jsoninput/nullableOrdered1.json` t1 " + + "FROM cp.`jsoninput/nullableOrdered1.json` t1 " + " LEFT OUTER JOIN " + " ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered2.json` t2 " + + " FROM cp.`jsoninput/nullableOrdered2.json` t2 " + " ORDER BY 1 DESC NULLS FIRST ) t2 " - + " USING ( key )", - TEST_RES_PATH, TEST_RES_PATH); + + " USING ( key )"; final int expectedRecordCount = 6; enableJoin(false, true); @@ -218,15 +205,13 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeLOJNullableOneOrderedInputDescNullsLast() throws Exception { String query = - String.format( "SELECT * " - + "FROM dfs_test.`%s/jsoninput/nullableOrdered1.json` t1 " + + "FROM cp.`jsoninput/nullableOrdered1.json` t1 " + " LEFT OUTER JOIN " + " ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered2.json` t2 " + + " FROM cp.`jsoninput/nullableOrdered2.json` t2 " + " ORDER BY 1 DESC NULLS LAST ) t2 " - + " USING ( key )", - TEST_RES_PATH, TEST_RES_PATH); + + " USING ( key )"; final int expectedRecordCount = 6; enableJoin(false, true); @@ -240,17 +225,15 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeLOJNullableBothInputsOrderedAscNullsFirstVsAscNullsFirst() throws Exception { String query = - String.format( "SELECT * " + "from ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered1.json` " + + " FROM cp.`jsoninput/nullableOrdered1.json` " + " ORDER BY 1 ASC NULLS FIRST ) t1 " + " LEFT OUTER JOIN " + " ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered2.json` " + + " FROM cp.`jsoninput/nullableOrdered2.json` " + " ORDER BY 1 ASC NULLS FIRST ) t2 " - + " USING ( key )", - TEST_RES_PATH, TEST_RES_PATH); + + " USING ( key )"; final int expectedRecordCount = 6; enableJoin(false, true); @@ -262,17 +245,15 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeLOJNullableBothInputsOrderedAscNullsLastVsAscNullsFirst() throws Exception { String query = - String.format( "SELECT * " + "from ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered1.json` " + + " FROM cp.`jsoninput/nullableOrdered1.json` " + " ORDER BY 1 ASC NULLS LAST ) t1 " + " LEFT OUTER JOIN " + " ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered2.json` " + + " FROM cp.`jsoninput/nullableOrdered2.json` " + " ORDER BY 1 ASC NULLS FIRST ) t2 " - + " USING ( key )", - TEST_RES_PATH, TEST_RES_PATH); + + " USING ( key )"; final int expectedRecordCount = 6; enableJoin(false, true); @@ -284,17 +265,15 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeLOJNullableBothInputsOrderedAscNullsFirstVsAscNullsLast() throws Exception { String query = - String.format( "SELECT * " + "from ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered1.json` " + + " FROM cp.`jsoninput/nullableOrdered1.json` " + " ORDER BY 1 ASC NULLS FIRST ) t1 " + " LEFT OUTER JOIN " + " ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered2.json` " + + " FROM cp.`jsoninput/nullableOrdered2.json` " + " ORDER BY 1 ASC NULLS LAST ) t2 " - + " USING ( key )", - TEST_RES_PATH, TEST_RES_PATH); + + " USING ( key )"; final int expectedRecordCount = 6; enableJoin(false, true); @@ -306,17 +285,15 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeLOJNullableBothInputsOrderedAscNullsLastVsAscNullsLast() throws Exception { String query = - String.format( "SELECT * " + "from ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered1.json` " + + " FROM cp.`jsoninput/nullableOrdered1.json` " + " ORDER BY 1 ASC NULLS LAST ) t1 " + " LEFT OUTER JOIN " + " ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered2.json` " + + " FROM cp.`jsoninput/nullableOrdered2.json` " + " ORDER BY 1 ASC NULLS LAST ) t2 " - + " USING ( key )", - TEST_RES_PATH, TEST_RES_PATH); + + " USING ( key )"; final int expectedRecordCount = 6; enableJoin(false, true); @@ -329,17 +306,15 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeLOJNullableBothInputsOrderedDescNullsFirstVsAscNullsFirst() throws Exception { String query = - String.format( "SELECT * " + "from ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered1.json` " + + " FROM cp.`jsoninput/nullableOrdered1.json` " + " ORDER BY 1 DESC NULLS FIRST ) t1 " + " LEFT OUTER JOIN " + " ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered2.json` " + + " FROM cp.`jsoninput/nullableOrdered2.json` " + " ORDER BY 1 ASC NULLS FIRST ) t2 " - + " USING ( key )", - TEST_RES_PATH, TEST_RES_PATH); + + " USING ( key )"; final int expectedRecordCount = 6; enableJoin(false, true); @@ -352,17 +327,15 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeLOJNullableBothInputsOrderedDescNullsLastVsAscNullsFirst() throws Exception { String query = - String.format( "SELECT * " + "from ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered1.json` " + + " FROM cp.`jsoninput/nullableOrdered1.json` " + " ORDER BY 1 DESC NULLS LAST ) t1 " + " LEFT OUTER JOIN " + " ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered2.json` " + + " FROM cp.`jsoninput/nullableOrdered2.json` " + " ORDER BY 1 ASC NULLS FIRST ) t2 " - + " USING ( key )", - TEST_RES_PATH, TEST_RES_PATH); + + " USING ( key )"; final int expectedRecordCount = 6; enableJoin(false, true); @@ -375,17 +348,15 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeLOJNullableBothInputsOrderedDescNullsFirstVsAscNullsLast() throws Exception { String query = - String.format( "SELECT * " + "from ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered1.json` " + + " FROM cp.`jsoninput/nullableOrdered1.json` " + " ORDER BY 1 DESC NULLS FIRST ) t1 " + " LEFT OUTER JOIN " + " ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered2.json` " + + " FROM cp.`jsoninput/nullableOrdered2.json` " + " ORDER BY 1 ASC NULLS LAST ) t2 " - + " USING ( key )", - TEST_RES_PATH, TEST_RES_PATH); + + " USING ( key )"; final int expectedRecordCount = 6; enableJoin(false, true); @@ -398,17 +369,15 @@ public class TestJoinNullable extends BaseTestQuery{ @Test public void testMergeLOJNullableBothInputsOrderedDescNullsLastVsAscNullsLast() throws Exception { String query = - String.format( "SELECT * " + "from ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered1.json` " + + " FROM cp.`jsoninput/nullableOrdered1.json` " + " ORDER BY 1 DESC NULLS LAST ) t1 " + " LEFT OUTER JOIN " + " ( SELECT key, data " - + " FROM dfs_test.`%s/jsoninput/nullableOrdered2.json` " + + " FROM cp.`jsoninput/nullableOrdered2.json` " + " ORDER BY 1 ASC NULLS LAST ) t2 " - + " USING ( key )", - TEST_RES_PATH, TEST_RES_PATH); + + " USING ( key )"; final int expectedRecordCount = 6; enableJoin(false, true); http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/TestMergeFilterPlan.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestMergeFilterPlan.java b/exec/java-exec/src/test/java/org/apache/drill/TestMergeFilterPlan.java index ab0acd2..4ac8580 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/TestMergeFilterPlan.java +++ b/exec/java-exec/src/test/java/org/apache/drill/TestMergeFilterPlan.java @@ -27,46 +27,42 @@ public class TestMergeFilterPlan extends PlanTestBase { @Test public void testDRILL_FilterMerge() throws Exception { - String viewDDL = "create or replace view MyViewWithFilter as " + - " SELECT first_name, " + - " last_name, " + - " full_name, " + - " salary, " + - " employee_id, " + - " store_id, " + - " position_id, " + - " position_title, " + - " education_level " + - " FROM cp.`employee.json` " + - " WHERE position_id in (1, 2, 3 ) " ; - - String querySQL = " select dat.store_id\n" + - " , sum(dat.store_cost) as total_cost\n" + - " from (\n" + - " select store_id, position_id\n" + - " , sum( salary) as store_cost\n" + - " from MyViewWithFilter \n" + - " where full_name in ( select n_name\n" + - " from cp.`tpch/nation.parquet`)\n" + - " and education_level = 'GRADUATE DEGREE' " + - " and position_id in ( select position_id \n" + - " from MyViewWithFilter\n" + - " where position_title like '%VP%'\n" + - " )\n" + - " group by store_id, position_id\n" + - ") dat\n" + - "group by dat.store_id\n" + - "order by dat.store_id"; - String expectedPattern1 = "Filter(condition=[AND(OR(=($0, 1), =($0, 2), =($0, 3)), =($4, 'GRADUATE DEGREE'))])"; String expectedPattern2 = "Filter(condition=[AND(OR(=($0, 1), =($0, 2), =($0, 3)), LIKE($1, '%VP%'))])"; String excludedPattern = "Filter(condition=[OR(=($0, 1), =($0, 2), =($0, 3))])"; - test("use dfs_test.tmp"); + test("use dfs.tmp"); - test(viewDDL); + test("create or replace view MyViewWithFilter as " + + " SELECT first_name, " + + " last_name, " + + " full_name, " + + " salary, " + + " employee_id, " + + " store_id, " + + " position_id, " + + " position_title, " + + " education_level " + + " FROM cp.`employee.json` " + + " WHERE position_id in (1, 2, 3 )"); - testPlanSubstrPatterns(querySQL, + testPlanSubstrPatterns(" select dat.store_id " + + " , sum(dat.store_cost) as total_cost " + + " from ( " + + " select store_id, position_id " + + " , sum(salary) as store_cost " + + " from MyViewWithFilter " + + " where full_name in ( select n_name " + + " from cp.`tpch/nation.parquet`) " + + " and education_level = 'GRADUATE DEGREE' " + + " and position_id in ( select position_id " + + " from MyViewWithFilter " + + " where position_title like '%VP%' " + + " ) " + + " group by store_id, position_id " + + ") dat " + + "group by dat.store_id " + + "order by dat.store_id", new String[]{expectedPattern1, expectedPattern2}, new String[]{excludedPattern}); test("drop view MyViewWithFilter "); http://git-wip-us.apache.org/repos/asf/drill/blob/acc5ed92/exec/java-exec/src/test/java/org/apache/drill/TestOutOfMemoryOutcome.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestOutOfMemoryOutcome.java b/exec/java-exec/src/test/java/org/apache/drill/TestOutOfMemoryOutcome.java index 9d78024..347c4ec 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/TestOutOfMemoryOutcome.java +++ b/exec/java-exec/src/test/java/org/apache/drill/TestOutOfMemoryOutcome.java @@ -22,6 +22,7 @@ import org.apache.drill.exec.exception.OutOfMemoryException; import org.apache.drill.exec.proto.CoordinationProtos; import org.apache.drill.exec.proto.UserBitShared.DrillPBError; import org.apache.drill.exec.testing.ControlsInjectionUtil; +import org.apache.drill.test.BaseTestQuery; import org.junit.Assert; import org.junit.Test; @@ -29,7 +30,7 @@ import org.junit.Test; * Run several tpch queries and inject an OutOfMemoryException in ScanBatch that will cause an OUT_OF_MEMORY outcome to * be propagated downstream. Make sure the proper "memory error" message is sent to the client. */ -public class TestOutOfMemoryOutcome extends BaseTestQuery{ +public class TestOutOfMemoryOutcome extends BaseTestQuery { private static final String SINGLE_MODE = "ALTER SESSION SET `planner.disable_exchanges` = true";