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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations