use of org.apache.drill.test.QueryRowSetIterator in project drill by apache.
the class TestMockPlugin method testSizeLimit.
/**
* By default, the mock reader limits batch size to 10 MB.
*/
@Test
public void testSizeLimit() throws RpcException {
String sql = "SELECT comments_s20000 FROM `mock`.`employee_1K`";
QueryRowSetIterator iter = client.queryBuilder().sql(sql).rowSetIterator();
assertTrue(iter.hasNext());
RowSet result = iter.next();
TupleMetadata schema = result.schema();
assertEquals(1, schema.size());
ColumnMetadata col = schema.metadata(0);
assertEquals("comments_s20000", col.name());
assertEquals(MinorType.VARCHAR, col.type());
assertEquals(DataMode.REQUIRED, col.mode());
assertTrue(result.rowCount() <= 10 * 1024 * 1024 / 20_000);
result.clear();
while (iter.hasNext()) {
iter.next().clear();
}
}
use of org.apache.drill.test.QueryRowSetIterator in project drill by apache.
the class TestLogReader method testWildcardLargeFile.
/**
* Tests for no crashes; does not validate results, unfortunately.
*/
@Test
public void testWildcardLargeFile() throws RpcException {
String sql = "SELECT * FROM cp.`regex/large.log1`";
QueryRowSetIterator iter = client.queryBuilder().sql(sql).rowSetIterator();
for (RowSet rowSet : iter) {
rowSet.clear();
}
}
use of org.apache.drill.test.QueryRowSetIterator in project drill by apache.
the class TestPagination method testAggregateQuery.
@Test
public void testAggregateQuery() throws Exception {
// Note that since the data arrives in multiple batches,
// in order to access the contents, we have to receive the batches and parse them.
// This is the case even with aggregate queries.
String sql = "SELECT ZONE, COUNT(*) AS row_count FROM `local`.`xml_paginator` GROUP BY ZONE";
try (MockWebServer server = startServer()) {
server.enqueue(new MockResponse().setResponseCode(200).setBody(TEST_XML_PAGE1));
server.enqueue(new MockResponse().setResponseCode(200).setBody(TEST_XML_PAGE2));
server.enqueue(new MockResponse().setResponseCode(200).setBody(TEST_XML_PAGE3));
QueryRowSetIterator iterator = client.queryBuilder().sql(sql).rowSetIterator();
TupleMetadata expectedSchema = new SchemaBuilder().addNullable("ZONE", MinorType.VARCHAR).add("row_count", MinorType.BIGINT).build();
RowSet expectedFirstRow = new RowSetBuilder(client.allocator(), expectedSchema).addRow("4", 5).build();
RowSet expectedSecondRow = new RowSetBuilder(client.allocator(), expectedSchema).addRow("3", 3).build();
int count = 0;
while (iterator.hasNext()) {
DirectRowSet results = iterator.next();
if (results.rowCount() > 0) {
if (count == 0) {
RowSetUtilities.verify(expectedFirstRow, results);
} else if (count == 1) {
RowSetUtilities.verify(expectedSecondRow, results);
}
count++;
}
}
}
}
Aggregations