use of org.apache.drill.exec.planner.logical.DrillParseContext in project drill by apache.
the class WindowPrel method toDrill.
protected LogicalExpression toDrill(AggregateCall call, List<String> fn) {
DrillParseContext context = new DrillParseContext(PrelUtil.getSettings(getCluster()));
List<LogicalExpression> args = Lists.newArrayList();
for (Integer i : call.getArgList()) {
final int indexInConstants = i - fn.size();
if (i < fn.size()) {
args.add(new FieldReference(fn.get(i)));
} else {
final RexLiteral constant = constants.get(indexInConstants);
LogicalExpression expr = DrillOptiq.toDrill(context, getInput(), constant);
args.add(expr);
}
}
// for count(1).
if (args.isEmpty()) {
args.add(new ValueExpressions.LongExpression(1l));
}
return new FunctionCall(call.getAggregation().getName().toLowerCase(), args, ExpressionPosition.UNKNOWN);
}
use of org.apache.drill.exec.planner.logical.DrillParseContext in project drill by apache.
the class ProjectPrel method getPhysicalOperator.
@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
Prel child = (Prel) this.getInput();
PhysicalOperator childPOP = child.getPhysicalOperator(creator);
org.apache.drill.exec.physical.config.Project p = new org.apache.drill.exec.physical.config.Project(this.getProjectExpressions(new DrillParseContext(PrelUtil.getSettings(getCluster()))), childPOP, outputProj);
return creator.addMetadata(this, p);
}
use of org.apache.drill.exec.planner.logical.DrillParseContext in project drill by apache.
the class ProjectAllowDupPrel method getPhysicalOperator.
@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
Prel child = (Prel) this.getInput();
PhysicalOperator childPOP = child.getPhysicalOperator(creator);
Project p = new Project(this.getProjectExpressions(new DrillParseContext(PrelUtil.getSettings(getCluster()))), childPOP, outputProj);
return creator.addMetadata(this, p);
}
use of org.apache.drill.exec.planner.logical.DrillParseContext in project drill by apache.
the class IcebergPluginImplementor method implement.
@Override
public void implement(PluginProjectRel project) throws IOException {
visitChild(project.getInput());
DrillParseContext context = new DrillParseContext(PrelUtil.getPlannerSettings(project.getCluster().getPlanner()));
RelNode input = project.getInput();
List<SchemaPath> projects = project.getProjects().stream().map(e -> (SchemaPath) DrillOptiq.toDrill(context, input, e)).collect(Collectors.toList());
groupScan = groupScan.clone(projects);
}
use of org.apache.drill.exec.planner.logical.DrillParseContext in project drill by apache.
the class IcebergPluginImplementor method canImplement.
@Override
public boolean canImplement(Filter filter) {
RexNode condition = filter.getCondition();
LogicalExpression logicalExpression = DrillOptiq.toDrill(new DrillParseContext(PrelUtil.getPlannerSettings(filter.getCluster().getPlanner())), filter.getInput(), condition);
Expression expression = logicalExpression.accept(DrillExprToIcebergTranslator.INSTANCE, null);
if (expression != null) {
try {
GroupScan scan = findGroupScan(filter);
if (scan instanceof IcebergGroupScan) {
IcebergGroupScan groupScan = (IcebergGroupScan) scan;
// ensures that expression compatible with table schema
expression = Binder.bind(groupScan.getTableScan().schema().asStruct(), expression, true);
} else {
return false;
}
} catch (ValidationException e) {
return false;
}
}
return expression != null;
}
Aggregations