Search in sources :

Example 1 with ClusterFixtureBuilder

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

the class TopNBatchTest method sortOneKeyAscending.

/**
 * End to end test of the TopN operator.
 * @throws Throwable
 */
@Test
public void sortOneKeyAscending() throws Throwable {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        TestBuilder testBuilder = new TestBuilder(new ClusterFixture.FixtureTestServices(client));
        testBuilder.ordered().physicalPlanFromFile("topN/one_key_sort.json").baselineColumns("blue").go();
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) TestBuilder(org.apache.drill.test.TestBuilder) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 2 with ClusterFixtureBuilder

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

the class TestHashAggrSpill method testSpill.

/**
 *  A template for Hash Aggr spilling tests
 *
 * @throws Exception
 */
private void testSpill(long maxMem, long numPartitions, long minBatches, int maxParallel, boolean fallback, boolean predict, String sql, long expectedRows, int cycle, int fromPart, int toPart) throws Exception {
    LogFixture.LogFixtureBuilder logBuilder = LogFixture.builder().toConsole().logger("org.apache.drill", Level.WARN);
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).sessionOption(ExecConstants.HASHAGG_MAX_MEMORY_KEY, maxMem).sessionOption(ExecConstants.HASHAGG_NUM_PARTITIONS_KEY, numPartitions).sessionOption(ExecConstants.HASHAGG_MIN_BATCHES_PER_PARTITION_KEY, minBatches).configProperty(ExecConstants.SYS_STORE_PROVIDER_LOCAL_ENABLE_WRITE, false).sessionOption(PlannerSettings.FORCE_2PHASE_AGGR_KEY, true).sessionOption(ExecConstants.HASHAGG_FALLBACK_ENABLED_KEY, fallback).sessionOption(ExecConstants.HASHAGG_USE_MEMORY_PREDICTION_KEY, predict).maxParallelization(maxParallel).saveProfiles();
    String sqlStr = // if null then use this default query
    sql != null ? // if null then use this default query
    sql : "SELECT empid_s17, dept_i, branch_i, AVG(salary_i) FROM `mock`.`employee_1200K` GROUP BY empid_s17, dept_i, branch_i";
    try (LogFixture logs = logBuilder.build();
        ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        runAndDump(client, sqlStr, expectedRows, cycle, fromPart, toPart);
    }
}
Also used : LogFixture(org.apache.drill.test.LogFixture) ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder)

Example 3 with ClusterFixtureBuilder

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

the class TestOrderedMuxExchange method testLimitOnOrderedMux.

/**
 * Test case to verify the OrderedMuxExchange created for order by with limit.
 * It checks that the limit is pushed down the OrderedMuxExchange.
 *
 * @throws Exception if anything goes wrong
 */
@Test
public void testLimitOnOrderedMux() 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 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 4 with ClusterFixtureBuilder

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

the class TestOrderedMuxExchange method testOrderedMuxForWindowAgg.

/**
 * Test case to verify the OrderedMuxExchange created for window functions.
 * 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 testOrderedMuxForWindowAgg() 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";
        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 5 with ClusterFixtureBuilder

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

the class TestValidationOptions method testConfig.

/**
 * Config options override session options. Config options allow passing in
 * the setting at run time on the command line. This is a work-around for the
 * fact that the config system has no generic solution at present.
 *
 * @throws Exception if anything goes wrong
 */
@Test
public void testConfig() throws Exception {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).maxParallelization(1).configProperty(ExecConstants.ENABLE_ITERATOR_VALIDATION, true).configProperty(ExecConstants.ENABLE_VECTOR_VALIDATION, true).sessionOption(ExecConstants.ENABLE_ITERATOR_VALIDATION_OPTION, false).sessionOption(ExecConstants.ENABLE_VECTOR_VALIDATION_OPTION, false);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        boolean hasAssertions = false;
        assert hasAssertions = true;
        assertFalse(hasAssertions);
        String sql = "SELECT id_i, name_s10 FROM `mock`.`customers_10`";
        client.queryBuilder().sql(sql).run();
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test) DrillTest(org.apache.drill.test.DrillTest)

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