Search in sources :

Example 51 with PhysicalOperator

use of org.apache.drill.exec.physical.base.PhysicalOperator 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 52 with PhysicalOperator

use of org.apache.drill.exec.physical.base.PhysicalOperator in project drill by apache.

the class UnionExchangePrel method getPhysicalOperator.

public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
    Prel child = (Prel) this.getInput();
    PhysicalOperator childPOP = child.getPhysicalOperator(creator);
    if (PrelUtil.getSettings(getCluster()).isSingleMode()) {
        return childPOP;
    }
    UnionExchange g = new UnionExchange(childPOP);
    return creator.addMetadata(this, g);
}
Also used : UnionExchange(org.apache.drill.exec.physical.config.UnionExchange) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator)

Example 53 with PhysicalOperator

use of org.apache.drill.exec.physical.base.PhysicalOperator in project drill by apache.

the class WriterPrel method getPhysicalOperator.

@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
    Prel child = (Prel) this.getInput();
    PhysicalOperator g = getCreateTableEntry().getWriter(child.getPhysicalOperator(creator));
    return creator.addMetadata(this, g);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator)

Example 54 with PhysicalOperator

use of org.apache.drill.exec.physical.base.PhysicalOperator in project drill by apache.

the class WindowPrel method getPhysicalOperator.

@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
    Prel child = (Prel) this.getInput();
    PhysicalOperator childPOP = child.getPhysicalOperator(creator);
    final List<String> childFields = getInput().getRowType().getFieldNames();
    // We don't support distinct partitions
    checkState(groups.size() == 1, "Only one window is expected in WindowPrel");
    Group window = groups.get(0);
    List<NamedExpression> withins = Lists.newArrayList();
    List<NamedExpression> aggs = Lists.newArrayList();
    List<Order.Ordering> orderings = Lists.newArrayList();
    for (int group : BitSets.toIter(window.keys)) {
        FieldReference fr = new FieldReference(childFields.get(group), ExpressionPosition.UNKNOWN);
        withins.add(new NamedExpression(fr, fr));
    }
    for (AggregateCall aggCall : window.getAggregateCalls(this)) {
        FieldReference ref = new FieldReference(aggCall.getName());
        LogicalExpression expr = toDrill(aggCall, childFields);
        aggs.add(new NamedExpression(expr, ref));
    }
    for (RelFieldCollation fieldCollation : window.orderKeys.getFieldCollations()) {
        orderings.add(new Order.Ordering(fieldCollation.getDirection(), new FieldReference(childFields.get(fieldCollation.getFieldIndex())), fieldCollation.nullDirection));
    }
    WindowPOP windowPOP = new WindowPOP(childPOP, withins, aggs, orderings, window.isRows, WindowPOP.newBound(window.lowerBound), WindowPOP.newBound(window.upperBound));
    creator.addMetadata(this, windowPOP);
    return windowPOP;
}
Also used : Order(org.apache.drill.common.logical.data.Order) FieldReference(org.apache.drill.common.expression.FieldReference) WindowPOP(org.apache.drill.exec.physical.config.WindowPOP) AggregateCall(org.apache.calcite.rel.core.AggregateCall) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) NamedExpression(org.apache.drill.common.logical.data.NamedExpression) RelFieldCollation(org.apache.calcite.rel.RelFieldCollation)

Example 55 with PhysicalOperator

use of org.apache.drill.exec.physical.base.PhysicalOperator in project drill by apache.

the class PhysicalPlanCreator method build.

public PhysicalPlan build(Prel rootPrel, boolean forceRebuild) {
    if (plan != null && !forceRebuild) {
        return plan;
    }
    PlanPropertiesBuilder propsBuilder = PlanProperties.builder();
    propsBuilder.type(PlanType.APACHE_DRILL_PHYSICAL);
    propsBuilder.version(1);
    propsBuilder.resultMode(ResultMode.EXEC);
    propsBuilder.generator(PhysicalPlanCreator.class.getName(), "");
    try {
        // invoke getPhysicalOperator on the root Prel which will recursively invoke it
        // on the descendants and we should have a well-formed physical operator tree
        PhysicalOperator rootPOP = rootPrel.getPhysicalOperator(this);
        if (rootPOP != null) {
            //getPhysicalOperator() is supposed to populate this list
            assert (popList.size() > 0);
            plan = new PhysicalPlan(propsBuilder.build(), popList);
        }
    } catch (IOException e) {
        plan = null;
        throw new UnsupportedOperationException("Physical plan created failed with error : " + e.toString());
    }
    return plan;
}
Also used : PhysicalPlan(org.apache.drill.exec.physical.PhysicalPlan) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) PlanPropertiesBuilder(org.apache.drill.common.logical.PlanProperties.PlanPropertiesBuilder) IOException(java.io.IOException)

Aggregations

PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)57 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)13 FragmentRoot (org.apache.drill.exec.physical.base.FragmentRoot)6 PhysicalPlanReader (org.apache.drill.exec.planner.PhysicalPlanReader)6 Test (org.junit.Test)6 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)4 Fragment (org.apache.drill.exec.planner.fragment.Fragment)4 DrillParseContext (org.apache.drill.exec.planner.logical.DrillParseContext)4 PlanFragment (org.apache.drill.exec.proto.BitControl.PlanFragment)4 IOException (java.io.IOException)3 RelNode (org.apache.calcite.rel.RelNode)3 RelDataType (org.apache.calcite.rel.type.RelDataType)3 DrillConfig (org.apache.drill.common.config.DrillConfig)3 FragmentContext (org.apache.drill.exec.ops.FragmentContext)3 OpProfileDef (org.apache.drill.exec.ops.OpProfileDef)3 OperatorStats (org.apache.drill.exec.ops.OperatorStats)3 QueryWorkUnit (org.apache.drill.exec.work.QueryWorkUnit)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 JoinRelType (org.apache.calcite.rel.core.JoinRelType)2 ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)2