@Test(expected = UserException.class) // see DRILL-2590 public void testUnionAllImplicitCastingFailure() 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\" " + "union all " + "select key from dfs_test.\"%s\" )", rootInt, rootBoolean); test(query); }
@Test public void testUnionAllViewExpandableStar() throws Exception { test("use dfs_test"); test("create view nation_view_testunionall as select n_name, n_nationkey from cp.\"tpch/nation.parquet\";"); test("create view region_view_testunionall as select r_name, r_regionkey from cp.\"tpch/region.parquet\";"); .build().run(); } finally { test("drop view nation_view_testunionall"); test("drop view region_view_testunionall");
@Test // DRILL-4147 // union-all above a hash join public void testDrill4147_3() throws Exception { final String l = FileUtils.getResourceAsFile("/multilevel/parquet/1994").toURI().toString(); final String r = FileUtils.getResourceAsFile("/multilevel/parquet/1995").toURI().toString(); final String query = String.format("SELECT o_custkey FROM \n" + " (select o1.o_custkey from dfs_test.\"%s\" o1 inner join dfs_test.\"%s\" o2 on o1.o_orderkey = o2.o_custkey) \n" + " Union All SELECT o_custkey FROM dfs_test.\"%s\" where o_custkey < 10", l, r, l); // Validate the plan final String[] expectedPlan = {"(?s)UnionExchange.*UnionAll.*HashJoin.*"}; final String[] excludedPlan = {}; try { test(sliceTargetSmall); PlanTestBase.testPlanMatchingPatterns(query, expectedPlan, excludedPlan); testBuilder() .optionSettingQueriesForTestQuery(sliceTargetSmall) .optionSettingQueriesForBaseline(sliceTargetDefault) .unOrdered() .sqlQuery(query) .sqlBaselineQuery(query) .build() .run(); } finally { test(sliceTargetDefault); } }
@Test // DRILL-4147 // group-by on top of union-all public void testDrill4147_2() throws Exception { final String l = FileUtils.getResourceAsFile("/multilevel/parquet/1994").toURI().toString(); final String r = FileUtils.getResourceAsFile("/multilevel/parquet/1995").toURI().toString(); final String query = String.format("Select o_custkey, count(*) as cnt from \n" + " (SELECT o_custkey FROM dfs_test.\"%s\" \n" + "Union All SELECT o_custkey FROM dfs_test.\"%s\") \n" + "group by o_custkey", l, r); // Validate the plan final String[] expectedPlan = {"(?s)UnionExchange.*HashAgg.*HashToRandomExchange.*UnionAll.*"}; final String[] excludedPlan = {}; try { test(sliceTargetSmall); PlanTestBase.testPlanMatchingPatterns(query, expectedPlan, excludedPlan); testBuilder() .optionSettingQueriesForTestQuery(sliceTargetSmall) .optionSettingQueriesForBaseline(sliceTargetDefault) .unOrdered() .sqlQuery(query) .sqlBaselineQuery(query) .build() .run(); } finally { test(sliceTargetDefault); } }
@Test // DRILL-4147 // 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 query = String.format("SELECT o_custkey FROM dfs_test.\"%s\" \n" + "Union All SELECT o_custkey FROM dfs_test.\"%s\"", l, r); // Validate the plan final String[] expectedPlan = {"UnionExchange.*\n", ".*Project.*\n" + ".*UnionAll"}; final String[] excludedPlan = {}; try { test(sliceTargetSmall); PlanTestBase.testPlanMatchingPatterns(query, expectedPlan, excludedPlan); testBuilder() .optionSettingQueriesForTestQuery(sliceTargetSmall) .optionSettingQueriesForBaseline(sliceTargetDefault) .unOrdered() .sqlQuery(query) .sqlBaselineQuery(query) .build() .run(); } finally { test(sliceTargetDefault); } }