Search in sources :

Example 26 with ClientFixture

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]"));
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) OperatorTest(org.apache.drill.categories.OperatorTest) SlowTest(org.apache.drill.categories.SlowTest) Test(org.junit.Test)

Example 27 with ClientFixture

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();
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test)

Example 28 with ClientFixture

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());
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) Matcher(java.util.regex.Matcher) ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test)

Example 29 with ClientFixture

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"));
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test)

Example 30 with ClientFixture

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"));
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test)

Aggregations

ClientFixture (org.apache.drill.test.ClientFixture)122 Test (org.junit.Test)102 ClusterFixture (org.apache.drill.test.ClusterFixture)99 ClusterFixtureBuilder (org.apache.drill.test.ClusterFixtureBuilder)89 SlowTest (org.apache.drill.categories.SlowTest)46 OptionsTest (org.apache.drill.categories.OptionsTest)36 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)28 BaseTest (org.apache.drill.test.BaseTest)20 ClusterTest (org.apache.drill.test.ClusterTest)16 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)12 DrillTest (org.apache.drill.test.DrillTest)10 OperatorTest (org.apache.drill.categories.OperatorTest)8 UserRemoteException (org.apache.drill.common.exceptions.UserRemoteException)7 RestClientFixture (org.apache.drill.test.RestClientFixture)4 ArrayList (java.util.ArrayList)3 SchemaPath (org.apache.drill.common.expression.SchemaPath)3 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)3 BigIntVector (org.apache.drill.exec.vector.BigIntVector)3 File (java.io.File)2 PlanFragment (org.apache.drill.exec.proto.BitControl.PlanFragment)2