use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.
the class TestOutputBatchBuilder method testReorder.
@Test
public void testReorder() {
TupleMetadata schema = firstSchema();
VectorContainer input = makeFirst(schema);
TupleMetadata outputSchema = new SchemaBuilder().add("a", MinorType.INT).add("d", MinorType.VARCHAR).buildSchema();
OutputBatchBuilder builder = new OutputBatchBuilder(outputSchema, Collections.singletonList(new BatchSource(schema, input)), fixture.allocator());
builder.load(input.getRecordCount());
VectorContainer output = builder.outputContainer();
RowSet expected = fixture.rowSetBuilder(outputSchema).addRow(10, "barney").addRow(20, "wilma").build();
RowSetUtilities.verify(expected, fixture.wrap(output));
}
use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.
the class TestOutputBatchBuilder method testMap.
@Test
public void testMap() {
final TupleMetadata schema = new SchemaBuilder().add("a", MinorType.VARCHAR).addMap("m").add("x", MinorType.INT).add("y", MinorType.VARCHAR).resumeSchema().buildSchema();
final VectorContainer input = fixture.rowSetBuilder(schema).addRow("barney", mapValue(1, "betty")).addRow("fred", mapValue(2, "wilma")).build().container();
final OutputBatchBuilder builder = new OutputBatchBuilder(schema, Collections.singletonList(new BatchSource(schema, input)), fixture.allocator());
builder.load(input.getRecordCount());
VectorContainer output = builder.outputContainer();
RowSetUtilities.verify(fixture.wrap(input), fixture.wrap(output));
}
use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.
the class TestOutputBatchBuilder method testTwoMaps.
@Test
public void testTwoMaps() {
final TupleMetadata schema1 = new SchemaBuilder().add("a", MinorType.VARCHAR).addMap("m").add("y", MinorType.VARCHAR).resumeSchema().buildSchema();
final VectorContainer input1 = fixture.rowSetBuilder(schema1).addRow("barney", mapValue("betty")).addRow("fred", mapValue("wilma")).build().container();
final TupleMetadata schema2 = new SchemaBuilder().addMap("m").add("x", MinorType.INT).resumeSchema().buildSchema();
final VectorContainer input2 = fixture.rowSetBuilder(schema2).addSingleCol(mapValue(1)).addSingleCol(mapValue(2)).build().container();
final TupleMetadata outputSchema = new SchemaBuilder().add("a", MinorType.VARCHAR).addMap("m").add("x", MinorType.INT).add("y", MinorType.VARCHAR).resumeSchema().buildSchema();
final RowSet expected = fixture.rowSetBuilder(outputSchema).addRow("barney", mapValue(1, "betty")).addRow("fred", mapValue(2, "wilma")).build();
OutputBatchBuilder builder = new OutputBatchBuilder(outputSchema, Lists.newArrayList(new BatchSource(schema1, input1), new BatchSource(schema2, input2)), fixture.allocator());
builder.load(input1.getRecordCount());
VectorContainer output = builder.outputContainer();
RowSetUtilities.verify(expected, fixture.wrap(output));
}
use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.
the class TestOutputBatchBuilder method testSingleInput.
@Test
public void testSingleInput() {
TupleMetadata schema = firstSchema();
VectorContainer input = makeFirst(schema);
OutputBatchBuilder builder = new OutputBatchBuilder(schema, Collections.singletonList(new BatchSource(schema, input)), fixture.allocator());
builder.load(input.getRecordCount());
VectorContainer output = builder.outputContainer();
RowSetUtilities.verify(fixture.wrap(input), fixture.wrap(output));
}
use of org.apache.drill.exec.physical.impl.scan.v3.lifecycle.OutputBatchBuilder.BatchSource in project drill by apache.
the class TestOutputBatchBuilder method testTwoInputs.
@Test
public void testTwoInputs() {
TupleMetadata schema1 = firstSchema();
VectorContainer input1 = makeFirst(schema1);
TupleMetadata schema2 = secondSchema();
VectorContainer input2 = makeSecond(schema2);
TupleMetadata outputSchema = new SchemaBuilder().add("a", MinorType.INT).add("b", MinorType.INT).add("c", MinorType.VARCHAR).add("d", MinorType.VARCHAR).buildSchema();
OutputBatchBuilder builder = new OutputBatchBuilder(outputSchema, Lists.newArrayList(new BatchSource(schema1, input1), new BatchSource(schema2, input2)), fixture.allocator());
builder.load(input1.getRecordCount());
VectorContainer output = builder.outputContainer();
SingleRowSet expected = fixture.rowSetBuilder(outputSchema).addRow(10, 1, "foo.csv", "barney").addRow(20, 2, "foo.csv", "wilma").build();
RowSetUtilities.verify(expected, fixture.wrap(output));
}
Aggregations