use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.ScanLifecycle in project drill by apache.
the class TestScanLifecycleBasics method testNoReaders.
/**
* Simplest possible do-nothing, default config case.
* Scan produces no valid schema.
*/
@Test
public void testNoReaders() {
ScanLifecycle scan = buildScan(new ScanLifecycleBuilder());
assertNull(scan.nextReader());
assertFalse(scan.hasOutputSchema());
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.ScanLifecycle in project drill by apache.
the class TestScanLifecycleBasics method testNullReader.
/**
* Single reader empty schema, EOF on first next().
* Since both no schema and no rows, we assume this to be a
* null (not empty) result set, so no output schema.
*/
@Test
public void testNullReader() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) {
return new MockLateSchemaReader(negotiator, 0);
}
});
ScanLifecycle scan = buildScan(builder);
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
assertFalse(reader.next());
assertFalse(scan.hasOutputSchema());
reader.close();
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.ScanLifecycle in project drill by apache.
the class TestFileScanLifecycle method testSingleCol.
@Test
public void testSingleCol() {
FileScanLifecycleBuilder builder = new FileScanLifecycleBuilder();
builder.projection(RowSetTestUtils.projectList(FileScanUtils.FILE_NAME_COL, SchemaPath.DYNAMIC_STAR));
builder.rootDir(MOCK_ROOT_PATH);
builder.fileSplits(Collections.singletonList(new DummyFileWork(MOCK_FILE_PATH)));
builder.readerFactory(new FileReaderFactory() {
@Override
public ManagedReader newReader(FileSchemaNegotiator negotiator) {
return new MockEarlySchemaReader(negotiator, 1);
}
});
ScanLifecycle scan = buildScan(builder);
assertSame(ProjectionType.ALL, scan.schemaTracker().projectionType());
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
assertTrue(reader.next());
TupleMetadata expectedSchema = new SchemaBuilder().add(FileScanUtils.FILE_NAME_COL, IMPLICIT_COL_TYPE).addAll(SCHEMA).build();
RowSet expected = fixture.rowSetBuilder(expectedSchema).addRow(MOCK_FILE_NAME, 10, "fred").addRow(MOCK_FILE_NAME, 20, "wilma").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.lifecycle.ScanLifecycle in project drill by apache.
the class TestFileScanLifecycle method testCtorUserError.
/**
* Verify that errors thrown from file-based readers include the file name
* in addition to the scan and reader level error contexts.
*/
@Test
public void testCtorUserError() {
FileScanLifecycleBuilder builder = new FileScanLifecycleBuilder();
builder.errorContext(b -> b.addContext("Scan context"));
builder.rootDir(MOCK_ROOT_PATH);
builder.maxPartitionDepth(3);
builder.projection(FileScanUtils.projectAllWithMetadata(3));
builder.fileSplits(Collections.singletonList(new DummyFileWork(MOCK_FILE_PATH)));
builder.useLegacyWildcardExpansion(true);
builder.readerFactory(new FileReaderFactory() {
@Override
public ManagedReader newReader(FileSchemaNegotiator negotiator) {
return new FailingReader(negotiator, "ctor-u");
}
});
ScanLifecycle scan = buildScan(builder);
RowBatchReader reader = scan.nextReader();
try {
reader.open();
fail();
} catch (UserException e) {
String msg = e.getMessage();
assertTrue(msg.contains("Oops ctor"));
assertTrue(msg.contains("My custom context"));
assertTrue(msg.contains("Scan context"));
assertTrue(msg.contains(MOCK_FILE_NAME));
assertNull(e.getCause());
}
scan.close();
}
use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.ScanLifecycle in project drill by apache.
the class TestFileScanLifecycle method testNoImplicit.
/**
* Sanity test that the file scan framework works the same as the base framework
* when no implicit columns are present.
*/
@Test
public void testNoImplicit() {
FileScanLifecycleBuilder builder = new FileScanLifecycleBuilder();
builder.rootDir(MOCK_ROOT_PATH);
builder.fileSplits(Collections.singletonList(new DummyFileWork(MOCK_FILE_PATH)));
builder.readerFactory(new FileReaderFactory() {
@Override
public ManagedReader newReader(FileSchemaNegotiator negotiator) {
return new MockEarlySchemaReader(negotiator, 1);
}
});
ScanLifecycle scan = buildScan(builder);
assertSame(ProjectionType.ALL, scan.schemaTracker().projectionType());
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
assertTrue(reader.next());
RowSetUtilities.verify(simpleExpected(0), fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
scan.close();
}
Aggregations