Search in sources :

Example 21 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.

the class TestResultSetLoaderEmptyProject method testNonEmptySchema.

/**
 * Verify that skip rows works even if the the projection is non-empty.
 */
@Test
public void testNonEmptySchema() {
    List<SchemaPath> selection = Lists.newArrayList(SchemaPath.getSimplePath("a"), SchemaPath.getSimplePath("b"));
    TupleMetadata schema = new SchemaBuilder().add("a", MinorType.INT).add("b", MinorType.INT).buildSchema();
    ResultSetOptions options = new ResultSetOptionBuilder().projection(Projections.parse(selection)).readerSchema(schema).build();
    ResultSetLoader rsLoader = new ResultSetLoaderImpl(fixture.allocator(), options);
    assertFalse(rsLoader.isProjectionEmpty());
    // Skip 10 rows. Columns are of required types, so are filled
    // with zeros.
    rsLoader.startBatch();
    int rowCount = 10;
    rsLoader.skipRows(rowCount);
    // Verify
    RowSetBuilder builder = fixture.rowSetBuilder(schema);
    for (int i = 0; i < rowCount; i++) {
        builder.addRow(0, 0);
    }
    RowSetUtilities.verify(builder.build(), fixture.wrap(rsLoader.harvest()));
    rsLoader.close();
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) ResultSetLoader(org.apache.drill.exec.physical.resultSet.ResultSetLoader) SchemaPath(org.apache.drill.common.expression.SchemaPath) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) ResultSetOptions(org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 22 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.

the class TestSorter method testEmptyRowSet.

// Test degenerate case: no rows
@Test
public void testEmptyRowSet() throws Exception {
    TupleMetadata schema = SortTestUtilities.nonNullSchema();
    SingleRowSet rowSet = new RowSetBuilder(fixture.allocator(), schema).withSv2().build();
    SingleRowSet expected = new RowSetBuilder(fixture.allocator(), schema).build();
    runSorterTest(rowSet, expected);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) DrillTest(org.apache.drill.test.DrillTest) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 23 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.

the class TestSorter method testTwoRows.

// Paranoia: sort with two rows.
@Test
public void testTwoRows() throws Exception {
    TupleMetadata schema = SortTestUtilities.nonNullSchema();
    SingleRowSet rowSet = new RowSetBuilder(fixture.allocator(), schema).addRow(1, "1").addRow(0, "0").withSv2().build();
    SingleRowSet expected = new RowSetBuilder(fixture.allocator(), schema).addRow(0, "0").addRow(1, "1").build();
    runSorterTest(rowSet, expected);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) DrillTest(org.apache.drill.test.DrillTest) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test)

Example 24 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.

the class TestResultSetCopier method testCopyRecord.

@Test
public void testCopyRecord() {
    ResultSetCopier copier = newCopier(new DataGen(3, 2));
    copier.startOutputBatch();
    copier.nextInputBatch();
    copier.copyRow(2);
    copier.copyRow(0);
    copier.copyRow(1);
    copier.nextInputBatch();
    copier.copyRow(1);
    copier.copyRow(0);
    copier.copyRow(2);
    assertFalse(copier.nextInputBatch());
    RowSet expected = new RowSetBuilder(fixture.allocator(), TEST_SCHEMA).addRow(3, "Row 3").addRow(1, "Row 1").addRow(2, "Row 2").addRow(5, "Row 5").addRow(4, "Row 4").addRow(6, "Row 6").build();
    RowSetUtilities.verify(expected, fixture.wrap(copier.harvest()));
    copier.close();
}
Also used : ResultSetCopier(org.apache.drill.exec.physical.resultSet.ResultSetCopier) RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test)

Example 25 with RowSetBuilder

use of org.apache.drill.exec.physical.rowSet.RowSetBuilder in project drill by apache.

the class TestPcapngStatRecordReader method testExplicitQuery.

@Test
public void testExplicitQuery() throws Exception {
    String sql = "select path, shb_hardware, shb_os, if_name, isb_ifrecv from dfs.`pcapng/sniff.pcapng`";
    QueryBuilder builder = client.queryBuilder().sql(sql);
    RowSet sets = builder.rowSet();
    TupleMetadata schema = new SchemaBuilder().addNullable("path", MinorType.VARCHAR).addNullable("shb_hardware", MinorType.VARCHAR).addNullable("shb_os", MinorType.VARCHAR).addNullable("if_name", MinorType.VARCHAR).addNullable("isb_ifrecv", MinorType.BIGINT).buildSchema();
    RowSet expected = new RowSetBuilder(client.allocator(), schema).addRow("sniff.pcapng", "Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz (with SSE4.2)", "Mac OS X 10.13.3, build 17D47 (Darwin 17.4.0)", null, null).addRow("sniff.pcapng", null, null, "en0", null).addRow("sniff.pcapng", null, null, null, 123).build();
    assertEquals(3, sets.rowCount());
    new RowSetComparison(expected).verifyAndClearAll(sets);
}
Also used : RowSetBuilder(org.apache.drill.exec.physical.rowSet.RowSetBuilder) RowSetComparison(org.apache.drill.test.rowSet.RowSetComparison) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) QueryBuilder(org.apache.drill.test.QueryBuilder) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Aggregations

RowSetBuilder (org.apache.drill.exec.physical.rowSet.RowSetBuilder)303 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)296 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)293 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)288 Test (org.junit.Test)282 ClusterTest (org.apache.drill.test.ClusterTest)153 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)140 DirectRowSet (org.apache.drill.exec.physical.rowSet.DirectRowSet)84 EvfTest (org.apache.drill.categories.EvfTest)64 QueryBuilder (org.apache.drill.test.QueryBuilder)45 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)28 SubOperatorTest (org.apache.drill.test.SubOperatorTest)27 QuerySummary (org.apache.drill.test.QueryBuilder.QuerySummary)26 SlowTest (org.apache.drill.categories.SlowTest)23 ValueVector (org.apache.drill.exec.vector.ValueVector)23 MockResponse (okhttp3.mockwebserver.MockResponse)21 MockWebServer (okhttp3.mockwebserver.MockWebServer)21 ColumnSize (org.apache.drill.exec.record.RecordBatchSizer.ColumnSize)20 RepeatedValueVector (org.apache.drill.exec.vector.complex.RepeatedValueVector)18 JdbcStorageTest (org.apache.drill.categories.JdbcStorageTest)17