Search in sources :

Example 6 with DrillProjectRel

use of org.apache.drill.exec.planner.logical.DrillProjectRel in project drill by apache.

the class DefaultSqlHandler method addRenamedProject.

protected DrillRel addRenamedProject(DrillRel rel, RelDataType validatedRowType) {
    RelDataType t = rel.getRowType();
    RexBuilder b = rel.getCluster().getRexBuilder();
    List<RexNode> projections = Lists.newArrayList();
    int projectCount = t.getFieldList().size();
    for (int i = 0; i < projectCount; i++) {
        projections.add(b.makeInputRef(rel, i));
    }
    final List<String> fieldNames2 = SqlValidatorUtil.uniquify(validatedRowType.getFieldNames(), SqlValidatorUtil.F_SUGGESTER2, rel.getCluster().getTypeFactory().getTypeSystem().isSchemaCaseSensitive());
    RelDataType newRowType = RexUtil.createStructType(rel.getCluster().getTypeFactory(), projections, fieldNames2);
    DrillProjectRel topProj = DrillProjectRel.create(rel.getCluster(), rel.getTraitSet(), rel, projections, newRowType);
    // Add a final non-trivial Project to get the validatedRowType, if child is not project.
    if (rel instanceof Project && DrillRelOptUtil.isTrivialProject(topProj, true)) {
        return rel;
    } else {
        return topProj;
    }
}
Also used : Project(org.apache.calcite.rel.core.Project) DrillProjectRel(org.apache.drill.exec.planner.logical.DrillProjectRel) RexBuilder(org.apache.calcite.rex.RexBuilder) RelDataType(org.apache.calcite.rel.type.RelDataType) RexNode(org.apache.calcite.rex.RexNode)

Aggregations

DrillProjectRel (org.apache.drill.exec.planner.logical.DrillProjectRel)6 DrillScanRel (org.apache.drill.exec.planner.logical.DrillScanRel)4 GroupScan (org.apache.drill.exec.physical.base.GroupScan)3 PlannerSettings (org.apache.drill.exec.planner.physical.PlannerSettings)3 RelOptRuleCall (org.apache.calcite.plan.RelOptRuleCall)2 TableScan (org.apache.calcite.rel.core.TableScan)2 RelDataType (org.apache.calcite.rel.type.RelDataType)2 RexNode (org.apache.calcite.rex.RexNode)2 DrillFilterRel (org.apache.drill.exec.planner.logical.DrillFilterRel)2 HiveScan (org.apache.drill.exec.store.hive.HiveScan)2 RelTraitSet (org.apache.calcite.plan.RelTraitSet)1 RelNode (org.apache.calcite.rel.RelNode)1 AggregateCall (org.apache.calcite.rel.core.AggregateCall)1 Project (org.apache.calcite.rel.core.Project)1 RexBuilder (org.apache.calcite.rex.RexBuilder)1 RexInputRef (org.apache.calcite.rex.RexInputRef)1 FileGroupScan (org.apache.drill.exec.physical.base.FileGroupScan)1 ParquetPartitionDescriptor (org.apache.drill.exec.planner.ParquetPartitionDescriptor)1 DrillAggregateRel (org.apache.drill.exec.planner.logical.DrillAggregateRel)1 PruneScanRule (org.apache.drill.exec.planner.logical.partition.PruneScanRule)1