Search in sources :

Example 6 with BatchSource

use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.

the class TestOutputBatchBuilder method testNestedMaps.

@Test
public void testNestedMaps() {
    final TupleMetadata schema1 = new SchemaBuilder().add("a", MinorType.VARCHAR).addMap("m1").add("p", MinorType.VARCHAR).addMap("m2").add("x", MinorType.VARCHAR).resumeMap().resumeSchema().buildSchema();
    final VectorContainer input1 = fixture.rowSetBuilder(schema1).addRow("barney", mapValue("betty", mapValue("pebbles"))).addRow("fred", mapValue("wilma", mapValue("bambam"))).build().container();
    final TupleMetadata schema2 = new SchemaBuilder().addMap("m1").add("q", MinorType.INT).addMap("m2").add("y", MinorType.INT).resumeMap().resumeSchema().buildSchema();
    final VectorContainer input2 = fixture.rowSetBuilder(schema2).addSingleCol(mapValue(1, mapValue(10))).addSingleCol(mapValue(2, mapValue(20))).build().container();
    final TupleMetadata outputSchema = new SchemaBuilder().add("a", MinorType.VARCHAR).addMap("m1").add("p", MinorType.VARCHAR).add("q", MinorType.INT).addMap("m2").add("x", MinorType.VARCHAR).add("y", MinorType.INT).resumeMap().resumeSchema().buildSchema();
    final RowSet expected = fixture.rowSetBuilder(outputSchema).addRow("barney", mapValue("betty", 1, mapValue("pebbles", 10))).addRow("fred", mapValue("wilma", 2, mapValue("bambam", 20))).build();
    OutputBatchBuilder builder = new OutputBatchBuilder(outputSchema, Arrays.asList(new BatchSource(schema1, input1), new BatchSource(schema2, input2)), fixture.allocator());
    builder.load(input1.getRecordCount());
    VectorContainer output = builder.outputContainer();
    RowSetUtilities.verify(expected, fixture.wrap(output));
}
Also used : TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) SchemaBuilder(org.apache.drill.exec.record.metadata.SchemaBuilder) SingleRowSet(org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet) RowSet(org.apache.drill.exec.physical.rowSet.RowSet) BatchSource(org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource) VectorContainer(org.apache.drill.exec.record.VectorContainer) SubOperatorTest(org.apache.drill.test.SubOperatorTest) Test(org.junit.Test) EvfTest(org.apache.drill.categories.EvfTest)

Example 7 with BatchSource

use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.

the class ReaderLifecycle method createOutputBuilder.

private void createOutputBuilder() {
    List<BatchSource> sources = new ArrayList<>();
    sources.add(new BatchSource(tableLoader.outputSchema(), tableLoader.outputContainer()));
    if (implicitColumnsLoader != null) {
        sources.add(new BatchSource(implicitColumnsLoader.schema(), implicitColumnsLoader.outputContainer()));
    }
    if (missingColumnsHandler != null) {
        sources.add(new BatchSource(missingColumnsHandler.schema(), missingColumnsHandler.outputContainer()));
    }
    outputBuilder = new OutputBatchBuilder(schemaTracker().outputSchema(), sources, scanLifecycle.allocator());
}
Also used : BatchSource(org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource) ArrayList(java.util.ArrayList)

Aggregations

BatchSource (org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource)7 EvfTest (org.apache.drill.categories.EvfTest)6 VectorContainer (org.apache.drill.exec.record.VectorContainer)6 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)6 SubOperatorTest (org.apache.drill.test.SubOperatorTest)6 Test (org.junit.Test)6 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)5 SingleRowSet (org.apache.drill.exec.physical.rowSet.RowSet.SingleRowSet)4 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)3 ArrayList (java.util.ArrayList)1