Search in sources :

Example 1 with QueryRowSetIterator

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();
    }
}
Also used : ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) QueryRowSetIterator(org.apache.drill.test.QueryRowSetIterator) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Example 2 with QueryRowSetIterator

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();
    }
}
Also used : QueryRowSetIterator(org.apache.drill.test.QueryRowSetIterator) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 3 with QueryRowSetIterator

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++;
            }
        }
    }
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) QueryRowSetIterator(org.apache.drill.test.QueryRowSetIterator) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) MockWebServer(okhttp3.mockwebserver.MockWebServer) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) DirectRowSet(org.apache.drill.exec.physical.rowSet.DirectRowSet) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) DirectRowSet(org.apache.drill.exec.physical.rowSet.DirectRowSet) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Aggregations

RowSet (org.apache.drill.exec.physical.rowSet.RowSet)3 ClusterTest (org.apache.drill.test.ClusterTest)3 QueryRowSetIterator (org.apache.drill.test.QueryRowSetIterator)3 Test (org.junit.Test)3 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)2 MockResponse (okhttp3.mockwebserver.MockResponse)1 MockWebServer (okhttp3.mockwebserver.MockWebServer)1 UnlikelyTest (org.apache.drill.categories.UnlikelyTest)1 DirectRowSet (org.apache.drill.exec.physical.rowSet.DirectRowSet)1 RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)1 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)1 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)1