use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestSemiJoin method testMultiColumnInClauseWithSemiJoin.
@Test
public void testMultiColumnInClauseWithSemiJoin() throws Exception {
String sql = "select * from cp.`employee.json` where (employee_id, full_name) in (select employee_id, full_name from cp.`employee.json` )";
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).setOptionDefault(PlannerSettings.SEMIJOIN.getOptionName(), true);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
String queryPlan = client.queryBuilder().sql(sql).explainText();
assertTrue(queryPlan.contains("semi-join: =[true]"));
}
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestLateralPlans method testUnnestWithAggInSubquery.
@Test
public void testUnnestWithAggInSubquery() throws Exception {
String sql = "select t.c_name, sum(t4.items) from cp.`lateraljoin/nested-customer.parquet` t," + " lateral (select t2.ord.items as items from unnest(t.orders) t2(ord)) d1," + " lateral (select sum(t3.items.i_number) from unnest(d1.items) t3(items)) t4(items) where t.c_id > 1 group by t.c_name";
String baselineQuery = "select t.c_name, sum(t3.items.i_number) from cp.`lateraljoin/nested-customer.parquet` t " + " inner join (select c_name, f, flatten(t1.f.items) from (select c_name, flatten(orders) as f from cp.`lateraljoin/nested-customer.parquet`) as t1 ) " + "t3(name, orders, items) on t.c_name = t3.name where t.c_id > 1 group by t.c_name";
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).setOptionDefault(PlannerSettings.ENABLE_UNNEST_LATERAL_KEY, true);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
client.testBuilder().ordered().sqlBaselineQuery(baselineQuery).sqlQuery(sql).go();
}
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestLateralPlans method testLateralAndUnnestExplainPlan.
// The following test is for testing the explain plan contains relation between lateral and corresponding unnest.
@Test
public void testLateralAndUnnestExplainPlan() throws Exception {
String sql = "select c.* from cp.`lateraljoin/nested-customer.json` c, unnest(c.orders) Orders(ord)";
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).setOptionDefault(PlannerSettings.ENABLE_UNNEST_LATERAL_KEY, true).setOptionDefault(ExecConstants.SLICE_TARGET, 1);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
String explain = client.queryBuilder().sql(sql).explainText();
String srcOp = explain.substring(explain.indexOf("srcOp"));
assertTrue(srcOp != null && srcOp.length() > 0);
String correlateFragmentPattern = srcOp.substring(srcOp.indexOf("=") + 1, srcOp.indexOf("]"));
assertTrue(correlateFragmentPattern != null && correlateFragmentPattern.length() > 0);
Matcher matcher = Pattern.compile(correlateFragmentPattern + ".*LateralJoin", Pattern.MULTILINE | Pattern.DOTALL).matcher(explain);
assertTrue(matcher.find());
}
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestLateralPlans method testNoExchangeWithOrderByWithoutLimit.
@Test
public void testNoExchangeWithOrderByWithoutLimit() throws Exception {
String Sql = "select d1.totalprice from dfs.`lateraljoin/multipleFiles` t," + " lateral ( select t2.ord.o_totalprice as totalprice from unnest(t.c_orders) t2(ord) order by t2.ord.o_orderkey) d1";
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).setOptionDefault(PlannerSettings.ENABLE_UNNEST_LATERAL_KEY, true).setOptionDefault(ExecConstants.SLICE_TARGET, 1);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
String explain = client.queryBuilder().sql(Sql).explainText();
String rightChild = getRightChildOfLateral(explain);
assertFalse(rightChild.contains("Exchange"));
}
}
use of org.apache.drill.test.ClientFixture in project drill by apache.
the class TestLateralPlans method testNoExchangeWithLateralsDownStreamAgg.
@Test
public void testNoExchangeWithLateralsDownStreamAgg() throws Exception {
String sql = "select sum(d1.totalprice) from dfs.`lateraljoin/multipleFiles` t, " + " lateral ( select t2.ord.o_totalprice as totalprice from unnest(t.c_orders) t2(ord) order by t2.ord.o_orderkey limit 10) d1 group by t.c_custkey";
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).setOptionDefault(PlannerSettings.ENABLE_UNNEST_LATERAL_KEY, true).setOptionDefault(ExecConstants.SLICE_TARGET, 1).setOptionDefault(PlannerSettings.HASHAGG.getOptionName(), false).setOptionDefault(PlannerSettings.STREAMAGG.getOptionName(), true);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
String explain = client.queryBuilder().sql(sql).explainText();
String rightChild = getRightChildOfLateral(explain);
assertFalse(rightChild.contains("Exchange"));
}
}
Aggregations