use of org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder in project drill by apache.
the class TestScanLifecycleBasics method testEarlySchemaTwoBatches.
@Test
public void testEarlySchemaTwoBatches() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) {
return new MockEarlySchemaReader(negotiator, 2);
}
});
ScanLifecycle scan = buildScan(builder);
assertSame(ProjectionType.ALL, scan.schemaTracker().projectionType());
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
assertEquals(SCHEMA, scan.outputSchema());
assertTrue(reader.next());
RowSetUtilities.verify(simpleExpected(0), fixture.wrap(reader.output()));
assertTrue(reader.next());
RowSetUtilities.verify(simpleExpected(1), fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder in project drill by apache.
the class TestScanLifecycleBasics method testEarlyEOF.
/**
* Single reader, late schema, early EOF.
* The scan never has a valid schema in this case.
*/
@Test
public void testEarlyEOF() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) throws EarlyEofException {
return new NoDataReader(negotiator);
}
});
ScanLifecycle scan = buildScan(builder);
RowBatchReader reader = scan.nextReader();
assertFalse(reader.open());
reader.close();
assertFalse(scan.hasOutputSchema());
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder in project drill by apache.
the class TestScanLifecycleBasics method testEarlySchemaWithProjectNone.
@Test
public void testEarlySchemaWithProjectNone() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.projection(RowSetTestUtils.projectNone());
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) {
return new MockEarlySchemaReader(negotiator, 1);
}
});
ScanLifecycle scan = buildScan(builder);
assertSame(ProjectionType.NONE, scan.schemaTracker().projectionType());
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
// Early schema: so output schema is available after open
TupleMetadata expectedSchema = new SchemaBuilder().build();
assertEquals(expectedSchema, scan.outputSchema());
assertTrue(reader.next());
RowSet expected = fixture.rowSetBuilder(expectedSchema).addRow().addRow().build();
RowSetUtilities.verify(expected, fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder in project drill by apache.
the class TestScanLifecycleBasics method testNullReaderWithSchema.
/**
* Single reader early schema, EOF on first next().
* Since this is an early-schema reader, there is an output
* schema even without any rows.
*/
@Test
public void testNullReaderWithSchema() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) {
return new MockEarlySchemaReader(negotiator, 0);
}
});
ScanLifecycle scan = buildScan(builder);
assertSame(ProjectionType.ALL, scan.schemaTracker().projectionType());
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
// Early schema: so output schema is available after open
assertTrue(scan.hasOutputSchema());
assertEquals(SCHEMA, scan.outputSchema());
assertTrue(reader.next());
VectorContainer result = reader.output();
assertEquals(0, result.getRecordCount());
result.zeroVectors();
// Early schema with no additional columns discovered
assertEquals(SCHEMA, scan.outputSchema());
// But, no second batch.
assertFalse(reader.next());
reader.close();
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder in project drill by apache.
the class TestScanLifecycleTwoReaders method testTwoNullReaders.
/**
* Two null readers: neither provides a valid scan schema.
*/
@Test
public void testTwoNullReaders() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.readerFactory(new TwoReaderFactory() {
@Override
public ManagedReader firstReader(SchemaNegotiator negotiator) {
return new MockLateSchemaReader(negotiator, 0);
}
@Override
public ManagedReader secondReader(SchemaNegotiator negotiator) {
return new MockLateSchemaReader(negotiator, 0);
}
});
ScanLifecycle scan = buildScan(builder);
verifyEmptyReader(scan);
verifyEmptyReader(scan);
scan.close();
}
Aggregations