Search in sources :

Example 66 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by axbaretto.

the class TestOrderedMuxExchange method testLimitOnOrderedMuxWindow.

/**
 * Test case to verify the OrderedMuxExchange created for order by with limit and window agg.
 * It checks that the limit is pushed down the OrderedMuxExchange.
 *
 * @throws Exception if anything goes wrong
 */
@Test
public void testLimitOnOrderedMuxWindow() throws Exception {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).maxParallelization(1).configProperty(ExecConstants.SYS_STORE_PROVIDER_LOCAL_ENABLE_WRITE, true);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        client.alterSession(ExecConstants.SLICE_TARGET, 10);
        String sql = "SELECT emp_name, max(emp_id) over (order by emp_name) FROM dfs.`empTable` e order BY emp_name limit 10";
        client.testBuilder().unOrdered().optionSettingQueriesForTestQuery("alter session set `planner.slice_target` = 10;").sqlQuery(sql).optionSettingQueriesForBaseline(// Use default option setting.
        "alter session set `planner.enable_ordered_mux_exchange` = false").sqlBaselineQuery(sql).build().run();
        client.alterSession(ExecConstants.ORDERED_MUX_EXCHANGE, true);
        String explainText = client.queryBuilder().sql(sql).explainText();
        assertTrue(explainText.matches(String.format(MATCH_PATTERN_ACROSS_LINES + "%s" + MATCH_PATTERN_ACROSS_LINES + "%s" + MATCH_PATTERN_ACROSS_LINES, ORDERED_MUX_EXCHANGE, TOPN)));
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test)

Example 67 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by axbaretto.

the class TestOrderedMuxExchange method testOrderedMuxForOrderBy.

/**
 * Test case to verify the OrderedMuxExchange created for order by clause.
 * It checks by forcing the plan to create OrderedMuxExchange and also verifies the
 * output column is ordered.
 *
 * @throws Exception if anything goes wrong
 */
@Test
public void testOrderedMuxForOrderBy() throws Exception {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).maxParallelization(1).configProperty(ExecConstants.SYS_STORE_PROVIDER_LOCAL_ENABLE_WRITE, true);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        client.alterSession(ExecConstants.SLICE_TARGET, 10);
        String sql = "SELECT emp_id, emp_name FROM dfs.`empTable` e order BY emp_name, emp_id";
        client.testBuilder().unOrdered().optionSettingQueriesForTestQuery("alter session set `planner.slice_target` = 10;").sqlQuery(sql).optionSettingQueriesForBaseline(// Use default option setting.
        "alter session set `planner.enable_ordered_mux_exchange` = false").sqlBaselineQuery(sql).build().run();
        client.alterSession(ExecConstants.ORDERED_MUX_EXCHANGE, true);
        String explainText = client.queryBuilder().sql(sql).explainText();
        assertTrue(explainText.contains(ORDERED_MUX_EXCHANGE));
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test)

Example 68 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by axbaretto.

the class TestPStoreProviders method localLoadTestHelper.

private void localLoadTestHelper(String propertiesDir) throws Exception {
    File localOptionsResources = new File(propertiesDir);
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).configProperty(ExecConstants.SYS_STORE_PROVIDER_CLASS, LocalPersistentStoreProvider.class.getCanonicalName()).configProperty(ExecConstants.SYS_STORE_PROVIDER_LOCAL_ENABLE_WRITE, true);
    File optionsDir = new File(dirTestWatcher.getStoreDir(), "sys.options");
    optionsDir.mkdirs();
    org.apache.commons.io.FileUtils.copyDirectory(localOptionsResources, optionsDir);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        String parquetPushdown = client.queryBuilder().sql("SELECT val FROM sys.%s where name='%s'", SystemTable.OPTION_VAL.getTableName(), PlannerSettings.PARQUET_ROWGROUP_FILTER_PUSHDOWN_PLANNING_THRESHOLD_KEY).singletonString();
        String plannerWidth = client.queryBuilder().sql("SELECT val FROM sys.%s where name='%s'", SystemTable.OPTION_VAL.getTableName(), ExecConstants.MAX_WIDTH_GLOBAL_KEY).singletonString();
        Assert.assertEquals("30000", parquetPushdown);
        Assert.assertEquals("3333", plannerWidth);
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) File(java.io.File)

Example 69 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by axbaretto.

the class DrillSeparatePlanningTest method getResultsHelper.

private int getResultsHelper(final QueryPlanFragments planFragments) throws Exception {
    int totalRows = 0;
    for (PlanFragment fragment : planFragments.getFragmentsList()) {
        DrillbitEndpoint assignedNode = fragment.getAssignment();
        ClientFixture fragmentClient = cluster.client(assignedNode.getAddress(), assignedNode.getUserPort());
        RowSet rowSet = fragmentClient.queryBuilder().sql("select hostname, user_port from sys.drillbits where `current`=true").rowSet();
        assertEquals(1, rowSet.rowCount());
        RowSetReader reader = rowSet.reader();
        assertTrue(reader.next());
        String host = reader.scalar("hostname").getString();
        int port = reader.scalar("user_port").getInt();
        rowSet.clear();
        assertEquals(assignedNode.getAddress(), host);
        assertEquals(assignedNode.getUserPort(), port);
        List<PlanFragment> fragmentList = Lists.newArrayList();
        fragmentList.add(fragment);
        QuerySummary summary = fragmentClient.queryBuilder().plan(fragmentList).run();
        totalRows += summary.recordCount();
        fragmentClient.close();
    }
    return totalRows;
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) QuerySummary(org.apache.drill.test.QueryBuilder.QuerySummary) ClientFixture(org.apache.drill.test.ClientFixture) RowSet(org.apache.drill.test.rowSet.RowSet) RowSetReader(org.apache.drill.test.rowSet.RowSetReader) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) PlanFragment(org.apache.drill.exec.proto.BitControl.PlanFragment)

Example 70 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by axbaretto.

the class TestConfigLinkage method testMaxWidthPerNodeDefault.

/* Test if max width is computed correctly using the cpu load average
     when the option is not set at either system or session level
  */
@Test
public void testMaxWidthPerNodeDefault() throws Exception {
    ClusterFixtureBuilder builder = ClusterFixture.bareBuilder(dirTestWatcher).setOptionDefault(ExecConstants.CPU_LOAD_AVERAGE_KEY, 0.70);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        long maxWidth = ExecConstants.MAX_WIDTH_PER_NODE.computeMaxWidth(0.70, 0);
        int availProc = Runtime.getRuntime().availableProcessors();
        long maxWidthPerNode = Math.max(1, Math.min(availProc, Math.round(availProc * 0.70)));
        assertEquals(maxWidthPerNode, maxWidth);
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test) OptionsTest(org.apache.drill.categories.OptionsTest) SlowTest(org.apache.drill.categories.SlowTest)

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