use of org.apache.drill.test.ClusterFixtureBuilder 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.ClusterFixtureBuilder 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.ClusterFixtureBuilder 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"));
}
}
use of org.apache.drill.test.ClusterFixtureBuilder in project drill by apache.
the class TestLateralPlans method testUnnestTableAndColumnAlias.
@Test
public void testUnnestTableAndColumnAlias() throws Exception {
String sql = "select t.c_name from cp.`lateraljoin/nested-customer.json` t, unnest(t.orders) ";
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).setOptionDefault(PlannerSettings.ENABLE_UNNEST_LATERAL_KEY, true);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
client.queryBuilder().sql(sql).run();
} catch (UserRemoteException ex) {
assertTrue(ex.getMessage().contains("Alias table and column name are required for UNNEST"));
}
}
use of org.apache.drill.test.ClusterFixtureBuilder in project drill by apache.
the class TestAnalyze method copyData.
@BeforeClass
public static void copyData() throws Exception {
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher);
startCluster(builder);
dirTestWatcher.copyResourceToRoot(Paths.get("multilevel", "parquet"));
}
Aggregations