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();
}
}
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();
}
}
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());
}
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");
}
}
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;
}
Aggregations