Search in sources :

Example 31 with QuerySummary

use of org.apache.drill.test.QueryBuilder.QuerySummary in project drill by axbaretto.

the class DrillSeparatePlanningTest method testPlanning.

@Test(timeout = 60_000)
public void testPlanning() throws Exception {
    final String query = "SELECT dir0, columns[3] FROM dfs.`multilevel/csv` order by dir0";
    client.alterSession("planner.slice_target", 1);
    try {
        // Original version, but no reason to dump output to test results.
        // long rows = client.queryBuilder().sql(query).print(Format.TSV, VectorUtil.DEFAULT_COLUMN_WIDTH);
        QuerySummary summary = client.queryBuilder().sql(query).run();
        assertEquals(120, summary.recordCount());
    } finally {
        client.resetSession("planner.slice_target");
    }
}
Also used : QuerySummary(org.apache.drill.test.QueryBuilder.QuerySummary) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) PlannerTest(org.apache.drill.categories.PlannerTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 32 with QuerySummary

use of org.apache.drill.test.QueryBuilder.QuerySummary in project drill by apache.

the class TestMockPlugin method testExtendedSqlMultiBatch.

@Test
public void testExtendedSqlMultiBatch() throws Exception {
    String sql = "SELECT id_i, name_s10 FROM `mock`.`employees_10K`";
    QuerySummary results = client.queryBuilder().sql(sql).run();
    assertEquals(10_000, results.recordCount());
}
Also used : QuerySummary(org.apache.drill.test.QueryBuilder.QuerySummary) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Example 33 with QuerySummary

use of org.apache.drill.test.QueryBuilder.QuerySummary in project drill by apache.

the class ExampleTest method secondTest.

/**
 * <p>
 *   Example that uses the fixture builder to build a cluster fixture. Lets
 *   you set configuration (boot-time) options, session options, system options
 *   and more.
 * </p>
 * <p>
 *   You can write test files to the {@link BaseDirTestWatcher#getRootDir()} and query them in the test.
 * </p>
 * <p>
 *   Also shows how to display the plan JSON and just run a query silently,
 *   getting just the row count, batch count and run time.
 * </p>
 * @throws Exception if anything goes wrong
 */
@Test
public void secondTest() throws Exception {
    try (RootAllocator allocator = new RootAllocator(100_000_000)) {
        final File tableFile = dirTestWatcher.getRootDir().toPath().resolve("employee.json").toFile();
        final TupleMetadata schema = new SchemaBuilder().add("id", Types.required(TypeProtos.MinorType.VARCHAR)).add("name", Types.required(TypeProtos.MinorType.VARCHAR)).buildSchema();
        final RowSet rowSet = new RowSetBuilder(allocator, schema).addRow("1", "kiwi").addRow("2", "watermelon").build();
        new JsonFileBuilder(rowSet).build(tableFile);
        rowSet.clear();
        ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).configProperty(ExecConstants.SLICE_TARGET, 10);
        try (ClusterFixture cluster = builder.build();
            ClientFixture client = cluster.clientFixture()) {
            String sql = "SELECT * FROM `dfs`.`test/employee.json`";
            logger.info(client.queryBuilder().sql(sql).explainJson());
            QuerySummary results = client.queryBuilder().sql(sql).run();
            logger.info(String.format("Read %d rows", results.recordCount()));
            // Usually we want to test something. Here, just test that we got
            // the 2 records.
            assertEquals(2, results.recordCount());
        }
    }
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RootAllocator(org.apache.drill.exec.memory.RootAllocator) QuerySummary(org.apache.drill.test.QueryBuilder.QuerySummary) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) JsonFileBuilder(org.apache.drill.test.rowSet.file.JsonFileBuilder) File(java.io.File) Test(org.junit.Test)

Example 34 with QuerySummary

use of org.apache.drill.test.QueryBuilder.QuerySummary in project drill by apache.

the class DrillSeparatePlanningTest method testPlanning.

@Test(timeout = 60_000)
public void testPlanning() throws Exception {
    final String query = "SELECT dir0, columns[3] FROM dfs.`multilevel/csv` order by dir0";
    client.alterSession("planner.slice_target", 1);
    try {
        // Original version, but no reason to dump output to test results.
        // long rows = client.queryBuilder().sql(query).print(Format.TSV, VectorUtil.DEFAULT_COLUMN_WIDTH);
        QuerySummary summary = client.queryBuilder().sql(query).run();
        assertEquals(120, summary.recordCount());
    } finally {
        client.resetSession("planner.slice_target");
    }
}
Also used : QuerySummary(org.apache.drill.test.QueryBuilder.QuerySummary) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) PlannerTest(org.apache.drill.categories.PlannerTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 35 with QuerySummary

use of org.apache.drill.test.QueryBuilder.QuerySummary in project drill by apache.

the class DrillSeparatePlanningTest method testSingleFragmentQuery.

@Test(timeout = 60_000)
public void testSingleFragmentQuery() throws Exception {
    final String query = "SELECT * FROM cp.`employee.json` where employee_id > 1 and employee_id < 1000";
    QueryPlanFragments planFragments = getFragmentsHelper(query);
    assertNotNull(planFragments);
    assertEquals(1, planFragments.getFragmentsCount());
    assertTrue(planFragments.getFragments(0).getLeafFragment());
    QuerySummary summary = client.queryBuilder().plan(planFragments.getFragmentsList()).run();
    assertEquals(997, summary.recordCount());
}
Also used : QueryPlanFragments(org.apache.drill.exec.proto.UserProtos.QueryPlanFragments) QuerySummary(org.apache.drill.test.QueryBuilder.QuerySummary) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) PlannerTest(org.apache.drill.categories.PlannerTest) SlowTest(org.apache.drill.categories.SlowTest)

Aggregations

QuerySummary (org.apache.drill.test.QueryBuilder.QuerySummary)49 Test (org.junit.Test)47 ClusterTest (org.apache.drill.test.ClusterTest)40 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)27 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)26 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)26 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)26 DirectRowSet (org.apache.drill.exec.physical.rowSet.DirectRowSet)25 JdbcStorageTest (org.apache.drill.categories.JdbcStorageTest)21 PlannerTest (org.apache.drill.categories.PlannerTest)6 SlowTest (org.apache.drill.categories.SlowTest)6 PlanFragment (org.apache.drill.exec.proto.BitControl.PlanFragment)4 QueryPlanFragments (org.apache.drill.exec.proto.UserProtos.QueryPlanFragments)4 Ignore (org.junit.Ignore)4 IOException (java.io.IOException)3 UserRemoteException (org.apache.drill.common.exceptions.UserRemoteException)3 Path (org.apache.hadoop.fs.Path)3 File (java.io.File)2 RootAllocator (org.apache.drill.exec.memory.RootAllocator)2 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)2