use of org.apache.drill.exec.planner.physical.Prel in project drill by apache.
the class MemoryEstimationVisitor method findCost.
private double findCost(Prel prel, RelMetadataQuery mq) {
DrillCostBase cost = (DrillCostBase) mq.getNonCumulativeCost(prel);
double memory = cost.getMemory();
for (Prel child : prel) {
memory += findCost(child, mq);
}
return memory;
}
use of org.apache.drill.exec.planner.physical.Prel in project drill by apache.
the class RewriteProjectToFlatten method visitPrel.
@Override
public Prel visitPrel(Prel prel, Object value) throws RelConversionException {
List<RelNode> children = Lists.newArrayList();
for (Prel child : prel) {
child = child.accept(this, null);
children.add(child);
}
return (Prel) prel.copy(prel.getTraitSet(), children);
}
use of org.apache.drill.exec.planner.physical.Prel in project drill by apache.
the class SelectionVectorPrelVisitor method visitPrel.
@Override
public Prel visitPrel(Prel prel, Void value) throws RuntimeException {
SelectionVectorMode[] encodings = prel.getSupportedEncodings();
List<RelNode> children = Lists.newArrayList();
for (Prel child : prel) {
child = child.accept(this, null);
children.add(convert(encodings, child));
}
return (Prel) prel.copy(prel.getTraitSet(), children);
}
use of org.apache.drill.exec.planner.physical.Prel in project drill by apache.
the class StarColumnConverter method visitPrel.
@Override
public Prel visitPrel(Prel prel, Void value) throws RuntimeException {
// Require prefix rename : there exists other expression, in addition to a star column.
if (// not set yet.
!prefixedForStar && StarColumnHelper.containsStarColumn(prel.getRowType()) && prel.getRowType().getFieldNames().size() > 1) {
prefixedForStar = true;
}
List<RelNode> children = Lists.newArrayList();
for (Prel child : prel) {
child = child.accept(this, null);
children.add(child);
}
return (Prel) prel.copy(prel.getTraitSet(), children);
}
use of org.apache.drill.exec.planner.physical.Prel in project drill by apache.
the class StarColumnConverter method visitProject.
@Override
public Prel visitProject(ProjectPrel prel, Void value) throws RuntimeException {
ProjectPrel proj = (ProjectPrel) prel;
// Require prefix rename : there exists other expression, in addition to a star column.
if (// not set yet.
!prefixedForStar && StarColumnHelper.containsStarColumnInProject(prel.getInput().getRowType(), proj.getProjects()) && prel.getRowType().getFieldNames().size() > 1) {
prefixedForStar = true;
}
// For project, we need make sure that the project's field name is same as the input,
// when the project expression is RexInPutRef, since we may insert a PAS which will
// rename the projected fields.
RelNode child = ((Prel) prel.getInput(0)).accept(this, null);
List<String> fieldNames = Lists.newArrayList();
for (Pair<String, RexNode> pair : Pair.zip(prel.getRowType().getFieldNames(), proj.getProjects())) {
if (pair.right instanceof RexInputRef) {
String name = child.getRowType().getFieldNames().get(((RexInputRef) pair.right).getIndex());
fieldNames.add(name);
} else {
fieldNames.add(pair.left);
}
}
// Make sure the field names are unique : no allow of duplicate field names in a rowType.
fieldNames = makeUniqueNames(fieldNames);
RelDataType rowType = RexUtil.createStructType(prel.getCluster().getTypeFactory(), proj.getProjects(), fieldNames);
ProjectPrel newProj = (ProjectPrel) proj.copy(proj.getTraitSet(), child, proj.getProjects(), rowType);
if (ProjectRemoveRule.isTrivial(newProj)) {
return (Prel) child;
} else {
return newProj;
}
}
Aggregations