Search in sources :

Example 51 with RowBatchReader

use of org.apache.drill.exec.physical.impl.scan.RowBatchReader in project drill by apache.

the class TestScanLifecycleSchema method testStrictProvidedSchemaSubset.

/**
 * Lenient provided schema which is a subset of the reader's schema; the
 * provided schema agrees with the reader types
 */
@Test
public void testStrictProvidedSchemaSubset() {
    TupleMetadata schema = new SchemaBuilder().addAll(SCHEMA).build();
    schema.setBooleanProperty(TupleMetadata.IS_STRICT_SCHEMA_PROP, true);
    ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
    builder.providedSchema(schema);
    builder.readerFactory(new SingleReaderFactory() {

        @Override
        public ManagedReader next(SchemaNegotiator negotiator) {
            return new MockThreeColReader(negotiator);
        }
    });
    ScanLifecycle scan = buildScan(builder);
    RowBatchReader reader = scan.nextReader();
    assertTrue(reader.open());
    assertEquals(SCHEMA, scan.outputSchema());
    assertTrue(reader.next());
    RowSet expected = fixture.rowSetBuilder(SCHEMA).addRow(101, "wilma").addRow(102, "betty").build();
    RowSetUtilities.verify(expected, fixture.wrap(reader.output()));
    assertFalse(reader.next());
    reader.close();
    scan.close();
}
Also used : RowBatchReader(org.apache.drill.exec.physical.impl.scan.RowBatchReader) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) ManagedReader(org.apache.drill.exec.physical.impl.scan.v3.ManagedReader) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) SchemaNegotiator(org.apache.drill.exec.physical.impl.scan.v3.SchemaNegotiator) ScanLifecycleBuilder(org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Aggregations

RowBatchReader (org.apache.drill.exec.physical.impl.scan.RowBatchReader)51 Test (org.junit.Test)48 ManagedReader (org.apache.drill.exec.physical.impl.scan.v3.ManagedReader)43 EvfTest (org.apache.drill.categories.EvfTest)42 ScanLifecycleBuilder (org.apache.drill.exec.physical.impl.scan.v3.ScanLifecycleBuilder)37 SchemaNegotiator (org.apache.drill.exec.physical.impl.scan.v3.SchemaNegotiator)37 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)28 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)13 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)13 UserException (org.apache.drill.common.exceptions.UserException)12 DummyFileWork (org.apache.drill.exec.physical.impl.scan.v3.file.BaseFileScanTest.DummyFileWork)6 BaseTestScanLifecycle (org.apache.drill.exec.physical.impl.scan.v3.lifecycle.BaseTestScanLifecycle)6 ScanLifecycle (org.apache.drill.exec.physical.impl.scan.v3.lifecycle.ScanLifecycle)6 SchemaPath (org.apache.drill.common.expression.SchemaPath)1 EarlyEofException (org.apache.drill.exec.physical.impl.scan.v3.ManagedReader.EarlyEofException)1 VectorContainer (org.apache.drill.exec.record.VectorContainer)1 Path (org.apache.hadoop.fs.Path)1