use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.
the class TestResultSetLoaderProjection method testScalarMapConflict.
@Test
public void testScalarMapConflict() {
List<SchemaPath> selection = RowSetTestUtils.projectList("col.child");
TupleMetadata schema = new SchemaBuilder().add("col", MinorType.VARCHAR).buildSchema();
ResultSetOptions options = new ResultSetOptionBuilder().projection(Projections.parse(selection)).readerSchema(schema).build();
try {
new ResultSetLoaderImpl(fixture.allocator(), options);
fail();
} catch (UserException e) {
assertTrue(e.getErrorType() == ErrorType.VALIDATION);
}
}
use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.
the class TestResultSetLoaderProjection method testArrayMapConflict.
@Test
public void testArrayMapConflict() {
List<SchemaPath> selection = RowSetTestUtils.projectList("col.child");
TupleMetadata schema = new SchemaBuilder().addArray("col", MinorType.VARCHAR).buildSchema();
ResultSetOptions options = new ResultSetOptionBuilder().projection(Projections.parse(selection)).readerSchema(schema).build();
try {
new ResultSetLoaderImpl(fixture.allocator(), options);
fail();
} catch (UserException e) {
assertTrue(e.getErrorType() == ErrorType.VALIDATION);
}
}
use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.
the class TestResultSetLoaderProjection method testProjectionDynamic.
@Test
public void testProjectionDynamic() {
List<SchemaPath> selection = RowSetTestUtils.projectList("c", "b", "e");
ResultSetOptions options = new ResultSetOptionBuilder().projection(Projections.parse(selection)).build();
ResultSetLoader rsLoader = new ResultSetLoaderImpl(fixture.allocator(), options);
RowSetLoader rootWriter = rsLoader.writer();
rootWriter.addColumn(SchemaBuilder.columnSchema("a", MinorType.INT, DataMode.REQUIRED));
rootWriter.addColumn(SchemaBuilder.columnSchema("b", MinorType.INT, DataMode.REQUIRED));
rootWriter.addColumn(SchemaBuilder.columnSchema("c", MinorType.INT, DataMode.REQUIRED));
rootWriter.addColumn(SchemaBuilder.columnSchema("d", MinorType.INT, DataMode.REQUIRED));
doProjectionTest(rsLoader);
}
use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.
the class TestResultSetLoaderProjection method testProjectWithOverflow.
/**
* Verify that the projection code plays nice with vector overflow. Overflow
* is the most complex operation in this subsystem with many specialized
* methods that must work together flawlessly. This test ensures that
* non-projected columns stay in the background and don't interfere
* with overflow logic.
*/
@Test
public void testProjectWithOverflow() {
List<SchemaPath> selection = RowSetTestUtils.projectList("small", "dummy");
TupleMetadata schema = new SchemaBuilder().add("big", MinorType.VARCHAR).add("small", MinorType.VARCHAR).buildSchema();
ResultSetOptions options = new ResultSetOptionBuilder().rowCountLimit(ValueVector.MAX_ROW_COUNT).projection(Projections.parse(selection)).readerSchema(schema).build();
ResultSetLoader rsLoader = new ResultSetLoaderImpl(fixture.allocator(), options);
RowSetLoader rootWriter = rsLoader.writer();
byte[] big = new byte[600];
Arrays.fill(big, (byte) 'X');
byte[] small = new byte[512];
Arrays.fill(small, (byte) 'X');
rsLoader.startBatch();
int count = 0;
while (!rootWriter.isFull()) {
rootWriter.start();
rootWriter.scalar(0).setBytes(big, big.length);
rootWriter.scalar(1).setBytes(small, small.length);
rootWriter.save();
count++;
}
// Number of rows should be driven by size of the
// projected vector ("small"), not by the larger, unprojected
// "big" vector.
// Our row count should include the overflow row
int expectedCount = ValueVector.MAX_BUFFER_SIZE / small.length;
assertEquals(expectedCount + 1, count);
// Loader's row count should include only "visible" rows
assertEquals(expectedCount, rootWriter.rowCount());
// Total count should include invisible and look-ahead rows.
assertEquals(expectedCount + 1, rsLoader.totalRowCount());
// Result should exclude the overflow row
RowSet result = fixture.wrap(rsLoader.harvest());
assertEquals(expectedCount, result.rowCount());
result.clear();
// Next batch should start with the overflow row
rsLoader.startBatch();
assertEquals(1, rootWriter.rowCount());
assertEquals(expectedCount + 1, rsLoader.totalRowCount());
result = fixture.wrap(rsLoader.harvest());
assertEquals(1, result.rowCount());
result.clear();
rsLoader.close();
}
use of org.apache.drill.exec.physical.resultSet.impl.ResultSetLoaderImpl.ResultSetOptions in project drill by apache.
the class TestResultSetLoaderProjection method testScalarArrayConflict.
@Test
public void testScalarArrayConflict() {
List<SchemaPath> selection = RowSetTestUtils.projectList("col[0]");
TupleMetadata schema = new SchemaBuilder().add("col", MinorType.VARCHAR).buildSchema();
ResultSetOptions options = new ResultSetOptionBuilder().projection(Projections.parse(selection)).readerSchema(schema).build();
try {
new ResultSetLoaderImpl(fixture.allocator(), options);
fail();
} catch (UserException e) {
assertTrue(e.getErrorType() == ErrorType.VALIDATION);
}
}
Aggregations