Search in sources :

Example 1 with UnionAll

use of org.apache.drill.exec.physical.config.UnionAll in project drill by apache.

the class UnionAllPrel method getPhysicalOperator.

@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
    List<PhysicalOperator> inputPops = Lists.newArrayList();
    for (int i = 0; i < this.getInputs().size(); i++) {
        inputPops.add(((Prel) this.getInputs().get(i)).getPhysicalOperator(creator));
    }
    UnionAll unionall = new UnionAll(inputPops);
    return creator.addMetadata(this, unionall);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) UnionAll(org.apache.drill.exec.physical.config.UnionAll)

Example 2 with UnionAll

use of org.apache.drill.exec.physical.config.UnionAll in project drill by apache.

the class TestMiniPlan method testUnionFilterAll.

@Test
@Ignore("DRILL-5327: A bug in UnionAll handling empty inputs from both sides")
public void testUnionFilterAll() throws Exception {
    List<String> leftJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 1 }]");
    List<String> rightJsonBatches = Lists.newArrayList("[{\"a\": 50, \"b\" : 10 }]");
    RecordBatch leftScan = new JsonScanBuilder().jsonBatches(leftJsonBatches).columnsToRead("a", "b").build();
    RecordBatch leftFilter = new PopBuilder().physicalOperator(new Filter(null, parseExpr("a < 0"), 1.0f)).addInput(leftScan).build();
    RecordBatch rightScan = new JsonScanBuilder().jsonBatches(rightJsonBatches).columnsToRead("a", "b").build();
    RecordBatch rightFilter = new PopBuilder().physicalOperator(new Filter(null, parseExpr("a < 0"), 1.0f)).addInput(rightScan).build();
    RecordBatch batch = new PopBuilder().physicalOperator(// Children list is provided through RecordBatch
    new UnionAll(Collections.EMPTY_LIST)).addInput(leftFilter).addInput(rightFilter).build();
    BatchSchema expectedSchema = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).addNullable("b", TypeProtos.MinorType.BIGINT).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
    new MiniPlanTestBuilder().root(batch).expectedSchema(expectedSchema).go();
}
Also used : Filter(org.apache.drill.exec.physical.config.Filter) BatchSchema(org.apache.drill.exec.record.BatchSchema) RecordBatch(org.apache.drill.exec.record.RecordBatch) SchemaBuilder(org.apache.drill.test.rowSet.SchemaBuilder) UnionAll(org.apache.drill.exec.physical.config.UnionAll) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with UnionAll

use of org.apache.drill.exec.physical.config.UnionAll in project drill by apache.

the class UnionDistinctPrel method getPhysicalOperator.

@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
    List<PhysicalOperator> inputPops = Lists.newArrayList();
    for (int i = 0; i < this.getInputs().size(); i++) {
        inputPops.add(((Prel) this.getInputs().get(i)).getPhysicalOperator(creator));
    }
    ///TODO: change this to UnionDistinct once implemented end-to-end..
    UnionAll unionAll = new UnionAll(inputPops);
    return creator.addMetadata(this, unionAll);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) UnionAll(org.apache.drill.exec.physical.config.UnionAll)

Example 4 with UnionAll

use of org.apache.drill.exec.physical.config.UnionAll in project drill by apache.

the class TestMiniPlan method testUnionFilter.

@Test
public void testUnionFilter() throws Exception {
    List<String> leftJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 1 }]", "[{\"a\": 5, \"b\" : 5},{\"a\": 3, \"b\" : 8}]", "[{\"a\": 40, \"b\" : 3},{\"a\": 13, \"b\" : 100}]");
    List<String> rightJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 10 }]", "[{\"a\": 50, \"b\" : 100}]");
    RecordBatch batch = new PopBuilder().physicalOperator(// Children list is provided through RecordBatch
    new UnionAll(Collections.EMPTY_LIST)).addInputAsChild().physicalOperator(new Filter(null, parseExpr("a=5"), 1.0f)).addJsonScanAsChild().jsonBatches(leftJsonBatches).columnsToRead("a", "b").buildAddAsInput().buildAddAsInput().addInputAsChild().physicalOperator(new Filter(null, parseExpr("a=50"), 1.0f)).addJsonScanAsChild().jsonBatches(rightJsonBatches).columnsToRead("a", "b").buildAddAsInput().buildAddAsInput().build();
    BatchSchema expectedSchema = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).addNullable("b", TypeProtos.MinorType.BIGINT).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
    new MiniPlanTestBuilder().root(batch).expectedSchema(expectedSchema).baselineValues(5l, 1l).baselineValues(5l, 5l).baselineValues(50l, 100l).go();
}
Also used : Filter(org.apache.drill.exec.physical.config.Filter) BatchSchema(org.apache.drill.exec.record.BatchSchema) RecordBatch(org.apache.drill.exec.record.RecordBatch) SchemaBuilder(org.apache.drill.test.rowSet.SchemaBuilder) UnionAll(org.apache.drill.exec.physical.config.UnionAll) Test(org.junit.Test)

Aggregations

UnionAll (org.apache.drill.exec.physical.config.UnionAll)4 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)2 Filter (org.apache.drill.exec.physical.config.Filter)2 BatchSchema (org.apache.drill.exec.record.BatchSchema)2 RecordBatch (org.apache.drill.exec.record.RecordBatch)2 SchemaBuilder (org.apache.drill.test.rowSet.SchemaBuilder)2 Test (org.junit.Test)2 Ignore (org.junit.Ignore)1