Search in sources :

Example 1 with PluginProjectRel

use of org.apache.drill.exec.store.plan.rel.PluginProjectRel in project drill by apache.

the class PluginProjectRule method convert.

@Override
public RelNode convert(RelNode rel) {
    Project project = (Project) rel;
    if (!getPluginImplementor().splitProject(project)) {
        return new PluginProjectRel(getOutConvention(), project.getCluster(), project.getTraitSet().replace(getOutConvention()), convert(project.getInput(), project.getTraitSet().replace(getOutConvention())), project.getProjects(), project.getRowType());
    }
    RelDataType inputRowType = project.getInput().getRowType();
    if (inputRowType.getFieldList().isEmpty()) {
        return null;
    }
    DrillRelOptUtil.ProjectPushInfo projectPushInfo = DrillRelOptUtil.getFieldsInformation(inputRowType, project.getProjects());
    Project pluginProject = createPluginProject(project, projectPushInfo);
    if (Utilities.isStarQuery(projectPushInfo.getFields()) || pluginProject.getRowType().equals(inputRowType)) {
        return null;
    }
    List<RexNode> newProjects = project.getChildExps().stream().map(n -> n.accept(projectPushInfo.getInputReWriter())).collect(Collectors.toList());
    Project newProject = createProject(project, pluginProject, newProjects);
    if (ProjectRemoveRule.isTrivial(newProject)) {
        return pluginProject;
    } else {
        return newProject;
    }
}
Also used : Convention(org.apache.calcite.plan.Convention) Project(org.apache.calcite.rel.core.Project) RelDataType(org.apache.calcite.rel.type.RelDataType) ExprToRex(org.apache.drill.exec.planner.index.ExprToRex) DrillRel(org.apache.drill.exec.planner.logical.DrillRel) RelNode(org.apache.calcite.rel.RelNode) Collectors(java.util.stream.Collectors) Utilities(org.apache.drill.exec.util.Utilities) List(java.util.List) RexNode(org.apache.calcite.rex.RexNode) DrillRelOptUtil(org.apache.drill.exec.planner.common.DrillRelOptUtil) RelTrait(org.apache.calcite.plan.RelTrait) DrillProjectRel(org.apache.drill.exec.planner.logical.DrillProjectRel) ProjectRemoveRule(org.apache.calcite.rel.rules.ProjectRemoveRule) PluginImplementor(org.apache.drill.exec.store.plan.PluginImplementor) PluginProjectRel(org.apache.drill.exec.store.plan.rel.PluginProjectRel) Project(org.apache.calcite.rel.core.Project) PluginProjectRel(org.apache.drill.exec.store.plan.rel.PluginProjectRel) DrillRelOptUtil(org.apache.drill.exec.planner.common.DrillRelOptUtil) RelDataType(org.apache.calcite.rel.type.RelDataType) RexNode(org.apache.calcite.rex.RexNode)

Example 2 with PluginProjectRel

use of org.apache.drill.exec.store.plan.rel.PluginProjectRel in project drill by apache.

the class PluginProjectRule method createPluginProject.

protected Project createPluginProject(Project project, DrillRelOptUtil.ProjectPushInfo projectPushInfo) {
    ExprToRex exprToRex = new ExprToRex(project.getInput(), project.getInput().getRowType(), project.getCluster().getRexBuilder());
    List<RexNode> newProjects = projectPushInfo.getFields().stream().map(f -> f.accept(exprToRex, null)).collect(Collectors.toList());
    return new PluginProjectRel(getOutConvention(), project.getCluster(), project.getTraitSet().replace(getOutConvention()), convert(project.getInput(), project.getTraitSet().replace(getOutConvention())), newProjects, projectPushInfo.createNewRowType(project.getCluster().getTypeFactory()));
}
Also used : Convention(org.apache.calcite.plan.Convention) Project(org.apache.calcite.rel.core.Project) RelDataType(org.apache.calcite.rel.type.RelDataType) ExprToRex(org.apache.drill.exec.planner.index.ExprToRex) DrillRel(org.apache.drill.exec.planner.logical.DrillRel) RelNode(org.apache.calcite.rel.RelNode) Collectors(java.util.stream.Collectors) Utilities(org.apache.drill.exec.util.Utilities) List(java.util.List) RexNode(org.apache.calcite.rex.RexNode) DrillRelOptUtil(org.apache.drill.exec.planner.common.DrillRelOptUtil) RelTrait(org.apache.calcite.plan.RelTrait) DrillProjectRel(org.apache.drill.exec.planner.logical.DrillProjectRel) ProjectRemoveRule(org.apache.calcite.rel.rules.ProjectRemoveRule) PluginImplementor(org.apache.drill.exec.store.plan.PluginImplementor) PluginProjectRel(org.apache.drill.exec.store.plan.rel.PluginProjectRel) ExprToRex(org.apache.drill.exec.planner.index.ExprToRex) PluginProjectRel(org.apache.drill.exec.store.plan.rel.PluginProjectRel) RexNode(org.apache.calcite.rex.RexNode)

Example 3 with PluginProjectRel

use of org.apache.drill.exec.store.plan.rel.PluginProjectRel 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);
}
Also used : Project(org.apache.calcite.rel.core.Project) IcebergGroupScan(org.apache.drill.exec.store.iceberg.IcebergGroupScan) RelShuttleImpl(org.apache.calcite.rel.RelShuttleImpl) Filter(org.apache.calcite.rel.core.Filter) RelSubset(org.apache.calcite.plan.volcano.RelSubset) AbstractPluginImplementor(org.apache.drill.exec.store.plan.AbstractPluginImplementor) BigDecimal(java.math.BigDecimal) DrillOptiq(org.apache.drill.exec.planner.logical.DrillOptiq) Expression(org.apache.iceberg.expressions.Expression) RexNode(org.apache.calcite.rex.RexNode) PluginProjectRel(org.apache.drill.exec.store.plan.rel.PluginProjectRel) DrillParseContext(org.apache.drill.exec.planner.logical.DrillParseContext) PrelUtil(org.apache.drill.exec.planner.physical.PrelUtil) PluginLimitRel(org.apache.drill.exec.store.plan.rel.PluginLimitRel) PluginFilterRel(org.apache.drill.exec.store.plan.rel.PluginFilterRel) Binder(org.apache.iceberg.expressions.Binder) RexLiteral(org.apache.calcite.rex.RexLiteral) SchemaPath(org.apache.drill.common.expression.SchemaPath) IOException(java.io.IOException) RelNode(org.apache.calcite.rel.RelNode) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) Collectors(java.util.stream.Collectors) ValidationException(org.apache.iceberg.exceptions.ValidationException) List(java.util.List) DrillLimitRelBase(org.apache.drill.exec.planner.common.DrillLimitRelBase) GroupScan(org.apache.drill.exec.physical.base.GroupScan) Util(org.apache.calcite.util.Util) StoragePluginTableScan(org.apache.drill.exec.store.plan.rel.StoragePluginTableScan) RelNode(org.apache.calcite.rel.RelNode) SchemaPath(org.apache.drill.common.expression.SchemaPath) DrillParseContext(org.apache.drill.exec.planner.logical.DrillParseContext)

Aggregations

List (java.util.List)3 Collectors (java.util.stream.Collectors)3 RelNode (org.apache.calcite.rel.RelNode)3 Project (org.apache.calcite.rel.core.Project)3 RexNode (org.apache.calcite.rex.RexNode)3 PluginProjectRel (org.apache.drill.exec.store.plan.rel.PluginProjectRel)3 Convention (org.apache.calcite.plan.Convention)2 RelTrait (org.apache.calcite.plan.RelTrait)2 ProjectRemoveRule (org.apache.calcite.rel.rules.ProjectRemoveRule)2 RelDataType (org.apache.calcite.rel.type.RelDataType)2 DrillRelOptUtil (org.apache.drill.exec.planner.common.DrillRelOptUtil)2 ExprToRex (org.apache.drill.exec.planner.index.ExprToRex)2 DrillProjectRel (org.apache.drill.exec.planner.logical.DrillProjectRel)2 DrillRel (org.apache.drill.exec.planner.logical.DrillRel)2 PluginImplementor (org.apache.drill.exec.store.plan.PluginImplementor)2 Utilities (org.apache.drill.exec.util.Utilities)2 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 RelSubset (org.apache.calcite.plan.volcano.RelSubset)1 RelShuttleImpl (org.apache.calcite.rel.RelShuttleImpl)1