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