use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.
the class TestResultSetLoaderEmptyProject method testDisjointMapProjection.
/**
* Test disjoint projection, but with maps. Project top-level columns
* a, b, when those columns actually appear in a map which is not
* projected.
*/
@Test
public void testDisjointMapProjection() {
List<SchemaPath> selection = Lists.newArrayList(SchemaPath.getSimplePath("a"), SchemaPath.getSimplePath("b"));
TupleMetadata schema = new SchemaBuilder().addMap("map").add("a", MinorType.INT).add("b", MinorType.INT).resumeSchema().buildSchema();
ResultSetOptions options = new ResultSetOptionBuilder().projection(Projections.parse(selection)).readerSchema(schema).build();
ResultSetLoader rsLoader = new ResultSetLoaderImpl(fixture.allocator(), options);
assertTrue(rsLoader.isProjectionEmpty());
rsLoader.close();
}
use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.
the class TestResultSetLoaderEmptyProject method testEmptyMapProjection.
@Test
public void testEmptyMapProjection() {
List<SchemaPath> selection = Lists.newArrayList();
TupleMetadata schema = new SchemaBuilder().addMap("map").add("a", MinorType.INT).add("b", MinorType.INT).resumeSchema().buildSchema();
ResultSetOptions options = new ResultSetOptionBuilder().projection(Projections.parse(selection)).readerSchema(schema).build();
ResultSetLoader rsLoader = new ResultSetLoaderImpl(fixture.allocator(), options);
assertTrue(rsLoader.isProjectionEmpty());
// Sanity test to verify row skipping with maps
int rowCount = 5000;
rsLoader.startBatch();
int skipped = rsLoader.skipRows(rowCount);
assertEquals(skipped, rowCount);
VectorContainer output = rsLoader.harvest();
assertEquals(rowCount, output.getRecordCount());
assertEquals(0, output.getNumberOfColumns());
output.zeroVectors();
rsLoader.close();
}
use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.
the class TestResultSetLoaderEmptyProject method testDisjointSchema.
/**
* Verify that a disjoint schema (projection does not overlap with
* table schema) is treated the same as an empty projection.
*/
@Test
public void testDisjointSchema() {
List<SchemaPath> selection = Lists.newArrayList(SchemaPath.getSimplePath("a"), SchemaPath.getSimplePath("b"));
TupleMetadata schema = new SchemaBuilder().add("c", MinorType.INT).add("d", MinorType.INT).buildSchema();
ResultSetOptions options = new ResultSetOptionBuilder().projection(Projections.parse(selection)).readerSchema(schema).build();
ResultSetLoader rsLoader = new ResultSetLoaderImpl(fixture.allocator(), options);
assertTrue(rsLoader.isProjectionEmpty());
rsLoader.close();
}
use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions 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.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.
the class TestResultSetLoaderLimits method testLimit100.
/**
* Test filling one batch normally, then hitting the scan limit on the second.
*/
@Test
public void testLimit100() {
ResultSetOptions options = new ResultSetOptionBuilder().rowCountLimit(75).limit(100).build();
ResultSetLoader rsLoader = new ResultSetLoaderImpl(fixture.allocator(), options);
RowSetLoader rootWriter = rsLoader.writer();
rootWriter.addColumn(SchemaBuilder.columnSchema("s", MinorType.VARCHAR, DataMode.REQUIRED));
rsLoader.startBatch();
int count = fillToLimit(rootWriter);
assertEquals(75, count);
assertEquals(count, rootWriter.rowCount());
rsLoader.harvest().clear();
assertFalse(rsLoader.atLimit());
// Second batch will hit the limit
rsLoader.startBatch();
count = fillToLimit(rootWriter);
assertEquals(25, count);
assertEquals(count, rootWriter.rowCount());
rsLoader.harvest().clear();
assertTrue(rsLoader.atLimit());
rsLoader.close();
}
Aggregations