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