Search in sources :

Example 26 with QuerySummary

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

the class ExampleTest method fifthTest.

/**
 * Example of a more realistic test that limits parallization, saves the query
 * profile, parses it, and displays the runtime timing results per operator.
 *
 * @throws Exception if anything goes wrong
 */
@Test
public void fifthTest() 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()) {
        String sql = "SELECT id_i, name_s10 FROM `mock`.`employees_10K` ORDER BY id_i";
        QuerySummary summary = client.queryBuilder().sql(sql).run();
        logger.info(String.format("Results: %,d records, %d batches, %,d ms", summary.recordCount(), summary.batchCount(), summary.runTimeMs()));
        logger.info("Query ID: " + summary.queryIdString());
        ProfileParser profile = client.parseProfile(summary.queryIdString());
        profile.print();
    }
}
Also used : QuerySummary(org.apache.drill.test.QueryBuilder.QuerySummary) Test(org.junit.Test)

Example 27 with QuerySummary

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

the class ExampleTest method fifthTest.

/**
 * Example of a more realistic test that limits parallization, saves the query
 * profile, parses it, and displays the runtime timing results per operator.
 *
 * @throws Exception if anything goes wrong
 */
@Test
public void fifthTest() 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()) {
        String sql = "SELECT id_i, name_s10 FROM `mock`.`employees_10K` ORDER BY id_i";
        QuerySummary summary = client.queryBuilder().sql(sql).run();
        System.out.println(String.format("Results: %,d records, %d batches, %,d ms", summary.recordCount(), summary.batchCount(), summary.runTimeMs()));
        System.out.println("Query ID: " + summary.queryIdString());
        ProfileParser profile = client.parseProfile(summary.queryIdString());
        profile.print();
    }
}
Also used : QuerySummary(org.apache.drill.test.QueryBuilder.QuerySummary) Test(org.junit.Test)

Example 28 with QuerySummary

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

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)

Example 29 with QuerySummary

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

the class DrillSeparatePlanningTest method testPlanningNoSplit.

@Test(timeout = 60_000)
public void testPlanningNoSplit() throws Exception {
    final String query = "SELECT dir0, sum(o_totalprice) FROM dfs.`multilevel/json` group by dir0 order by dir0";
    client.alterSession("planner.slice_target", 1);
    try {
        final QueryPlanFragments planFragments = client.planQuery(query);
        assertNotNull(planFragments);
        assertTrue((planFragments.getFragmentsCount() > 1));
        PlanFragment rootFragment = planFragments.getFragments(0);
        assertFalse(rootFragment.getLeafFragment());
        QuerySummary summary = client.queryBuilder().plan(planFragments.getFragmentsList()).run();
        assertEquals(3, summary.recordCount());
    } finally {
        client.resetSession("planner.slice_target");
    }
}
Also used : QueryPlanFragments(org.apache.drill.exec.proto.UserProtos.QueryPlanFragments) QuerySummary(org.apache.drill.test.QueryBuilder.QuerySummary) PlanFragment(org.apache.drill.exec.proto.BitControl.PlanFragment) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) PlannerTest(org.apache.drill.categories.PlannerTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 30 with QuerySummary

use of org.apache.drill.test.QueryBuilder.QuerySummary 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)

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