Search in sources :

Example 6 with RelOptRuleCall

use of org.apache.calcite.plan.RelOptRuleCall in project drill by apache.

the class ParquetPruneScanRule method getFilterOnProjectParquet.

public static final RelOptRule getFilterOnProjectParquet(OptimizerRulesContext optimizerRulesContext) {
    return new PruneScanRule(RelOptHelper.some(DrillFilterRel.class, RelOptHelper.some(DrillProjectRel.class, RelOptHelper.any(DrillScanRel.class))), "PruneScanRule:Filter_On_Project_Parquet", optimizerRulesContext) {

        @Override
        public PartitionDescriptor getPartitionDescriptor(PlannerSettings settings, TableScan scanRel) {
            return new ParquetPartitionDescriptor(settings, (DrillScanRel) scanRel);
        }

        @Override
        public boolean matches(RelOptRuleCall call) {
            final DrillScanRel scan = call.rel(2);
            GroupScan groupScan = scan.getGroupScan();
            // this rule is applicable only for parquet based partition pruning
            if (PrelUtil.getPlannerSettings(scan.getCluster().getPlanner()).isHepPartitionPruningEnabled()) {
                return groupScan instanceof ParquetGroupScan && groupScan.supportsPartitionFilterPushdown() && !scan.partitionFilterPushdown();
            } else {
                return groupScan instanceof ParquetGroupScan && groupScan.supportsPartitionFilterPushdown();
            }
        }

        @Override
        public void onMatch(RelOptRuleCall call) {
            final DrillFilterRel filterRel = call.rel(0);
            final DrillProjectRel projectRel = call.rel(1);
            final DrillScanRel scanRel = call.rel(2);
            doOnMatch(call, filterRel, projectRel, scanRel);
        }
    };
}
Also used : FileGroupScan(org.apache.drill.exec.physical.base.FileGroupScan) GroupScan(org.apache.drill.exec.physical.base.GroupScan) ParquetGroupScan(org.apache.drill.exec.store.parquet.ParquetGroupScan) TableScan(org.apache.calcite.rel.core.TableScan) DrillScanRel(org.apache.drill.exec.planner.logical.DrillScanRel) PlannerSettings(org.apache.drill.exec.planner.physical.PlannerSettings) DrillProjectRel(org.apache.drill.exec.planner.logical.DrillProjectRel) DrillFilterRel(org.apache.drill.exec.planner.logical.DrillFilterRel) ParquetGroupScan(org.apache.drill.exec.store.parquet.ParquetGroupScan) RelOptRuleCall(org.apache.calcite.plan.RelOptRuleCall) ParquetPartitionDescriptor(org.apache.drill.exec.planner.ParquetPartitionDescriptor)

Aggregations

RelOptRuleCall (org.apache.calcite.plan.RelOptRuleCall)6 TableScan (org.apache.calcite.rel.core.TableScan)4 GroupScan (org.apache.drill.exec.physical.base.GroupScan)4 DrillFilterRel (org.apache.drill.exec.planner.logical.DrillFilterRel)4 DrillScanRel (org.apache.drill.exec.planner.logical.DrillScanRel)4 PlannerSettings (org.apache.drill.exec.planner.physical.PlannerSettings)4 FileGroupScan (org.apache.drill.exec.physical.base.FileGroupScan)2 ParquetPartitionDescriptor (org.apache.drill.exec.planner.ParquetPartitionDescriptor)2 DrillProjectRel (org.apache.drill.exec.planner.logical.DrillProjectRel)2 PruneScanRule (org.apache.drill.exec.planner.logical.partition.PruneScanRule)2 FilterPrel (org.apache.drill.exec.planner.physical.FilterPrel)2 ScanPrel (org.apache.drill.exec.planner.physical.ScanPrel)2 HivePartitionDescriptor (org.apache.drill.exec.planner.sql.HivePartitionDescriptor)2 HiveScan (org.apache.drill.exec.store.hive.HiveScan)2 ParquetGroupScan (org.apache.drill.exec.store.parquet.ParquetGroupScan)2 ProjectPrel (org.apache.drill.exec.planner.physical.ProjectPrel)1