use of org.apache.drill.exec.physical.impl.scan.v3.SchemaNegotiator 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.SchemaNegotiator 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.SchemaNegotiator 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.SchemaNegotiator 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();
}
use of org.apache.drill.exec.physical.impl.scan.v3.SchemaNegotiator in project drill by apache.
the class TestScanLifecycleTwoReaders method testColumnReorderingBA.
/**
* {@code SELECT * FROM} (b,a) then (a, b). The order of the first
* table drives the order of the results.
*/
@Test
public void testColumnReorderingBA() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.readerFactory(new TwoReaderFactory() {
@Override
public ManagedReader firstReader(SchemaNegotiator negotiator) {
return new MockReorderedReader(negotiator);
}
@Override
public ManagedReader secondReader(SchemaNegotiator negotiator) {
return new MockLateSchemaReader(negotiator, 1);
}
});
ScanLifecycle scan = buildScan(builder);
RowBatchReader reader = scan.nextReader();
reader = scan.nextReader();
assertTrue(reader.open());
assertTrue(reader.next());
RowSet expected = fixture.rowSetBuilder(MockReorderedReader.READER_SCHEMA).addRow("barney", 30).addRow("betty", 40).build();
RowSetUtilities.verify(expected, fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
reader = scan.nextReader();
reader = scan.nextReader();
assertTrue(reader.open());
assertTrue(reader.next());
expected = fixture.rowSetBuilder(MockReorderedReader.READER_SCHEMA).addRow("fred", 10).addRow("wilma", 20).build();
RowSetUtilities.verify(expected, fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
scan.close();
}
Aggregations