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