Search in sources :

Example 31 with ClusterFixtureBuilder

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());
    }
}
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 32 with ClusterFixtureBuilder

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"));
    }
}
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 33 with ClusterFixtureBuilder

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"));
    }
}
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 34 with ClusterFixtureBuilder

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

Example 35 with ClusterFixtureBuilder

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"));
}
Also used : ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) BeforeClass(org.junit.BeforeClass)

Aggregations

ClusterFixtureBuilder (org.apache.drill.test.ClusterFixtureBuilder)156 ClusterFixture (org.apache.drill.test.ClusterFixture)102 Test (org.junit.Test)93 ClientFixture (org.apache.drill.test.ClientFixture)89 BeforeClass (org.junit.BeforeClass)47 SlowTest (org.apache.drill.categories.SlowTest)44 OptionsTest (org.apache.drill.categories.OptionsTest)34 BaseTest (org.apache.drill.test.BaseTest)27 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)15 DrillTest (org.apache.drill.test.DrillTest)14 OperatorTest (org.apache.drill.categories.OperatorTest)8 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)8 FileSystemConfig (org.apache.drill.exec.store.dfs.FileSystemConfig)6 StoragePluginConfig (org.apache.drill.common.logical.StoragePluginConfig)5 PluginException (org.apache.drill.exec.store.StoragePluginRegistry.PluginException)5 File (java.io.File)4 ResourceManagerTest (org.apache.drill.categories.ResourceManagerTest)4 DefaultResourceManager (org.apache.drill.exec.work.foreman.rm.DefaultResourceManager)4 DistributedResourceManager (org.apache.drill.exec.work.foreman.rm.DistributedResourceManager)4 ResourceManager (org.apache.drill.exec.work.foreman.rm.ResourceManager)4