use of org.apache.drill.exec.planner.physical.FilterPrel in project drill by apache.
the class MongoPushDownFilterForScan method onMatch.
@Override
public void onMatch(RelOptRuleCall call) {
final ScanPrel scan = (ScanPrel) call.rel(1);
final FilterPrel filter = (FilterPrel) call.rel(0);
final RexNode condition = filter.getCondition();
MongoGroupScan groupScan = (MongoGroupScan) scan.getGroupScan();
if (groupScan.isFilterPushedDown()) {
return;
}
LogicalExpression conditionExp = DrillOptiq.toDrill(new DrillParseContext(PrelUtil.getPlannerSettings(call.getPlanner())), scan, condition);
MongoFilterBuilder mongoFilterBuilder = new MongoFilterBuilder(groupScan, conditionExp);
MongoScanSpec newScanSpec = mongoFilterBuilder.parseTree();
if (newScanSpec == null) {
// no filter pushdown so nothing to apply.
return;
}
MongoGroupScan newGroupsScan = null;
try {
newGroupsScan = new MongoGroupScan(groupScan.getUserName(), groupScan.getStoragePlugin(), newScanSpec, groupScan.getColumns());
} catch (IOException e) {
logger.error(e.getMessage(), e);
throw new DrillRuntimeException(e.getMessage(), e);
}
newGroupsScan.setFilterPushedDown(true);
final ScanPrel newScanPrel = ScanPrel.create(scan, filter.getTraitSet(), newGroupsScan, scan.getRowType());
if (mongoFilterBuilder.isAllExpressionsConverted()) {
/*
* Since we could convert the entire filter condition expression into an
* Mongo filter, we can eliminate the filter operator altogether.
*/
call.transformTo(newScanPrel);
} else {
call.transformTo(filter.copy(filter.getTraitSet(), ImmutableList.of((RelNode) newScanPrel)));
}
}
use of org.apache.drill.exec.planner.physical.FilterPrel in project drill by apache.
the class ParquetPushDownFilter method getFilterOnProject.
public static RelOptRule getFilterOnProject(OptimizerRulesContext optimizerRulesContext) {
return new ParquetPushDownFilter(RelOptHelper.some(FilterPrel.class, RelOptHelper.some(ProjectPrel.class, RelOptHelper.any(ScanPrel.class))), "ParquetPushDownFilter:Filter_On_Project", optimizerRulesContext) {
@Override
public boolean matches(RelOptRuleCall call) {
final ScanPrel scan = call.rel(2);
if (scan.getGroupScan() instanceof ParquetGroupScan) {
return super.matches(call);
}
return false;
}
@Override
public void onMatch(RelOptRuleCall call) {
final FilterPrel filterRel = call.rel(0);
final ProjectPrel projectRel = call.rel(1);
final ScanPrel scanRel = call.rel(2);
doOnMatch(call, filterRel, projectRel, scanRel);
}
};
}
use of org.apache.drill.exec.planner.physical.FilterPrel in project drill by axbaretto.
the class ParquetPushDownFilter method getFilterOnScan.
public static StoragePluginOptimizerRule getFilterOnScan(OptimizerRulesContext optimizerContext) {
return new ParquetPushDownFilter(RelOptHelper.some(FilterPrel.class, RelOptHelper.any(ScanPrel.class)), "ParquetPushDownFilter:Filter_On_Scan", optimizerContext) {
@Override
public boolean matches(RelOptRuleCall call) {
final ScanPrel scan = call.rel(1);
if (scan.getGroupScan() instanceof ParquetGroupScan) {
return super.matches(call);
}
return false;
}
@Override
public void onMatch(RelOptRuleCall call) {
final FilterPrel filterRel = call.rel(0);
final ScanPrel scanRel = call.rel(1);
doOnMatch(call, filterRel, null, scanRel);
}
};
}
use of org.apache.drill.exec.planner.physical.FilterPrel in project drill by apache.
the class FilePushDownFilter method getFilterOnScan.
public static StoragePluginOptimizerRule getFilterOnScan(OptimizerRulesContext optimizerContext) {
return new FilePushDownFilter(RelOptHelper.some(FilterPrel.class, RelOptHelper.any(ScanPrel.class)), "FilePushDownFilter:Filter_On_Scan", optimizerContext) {
@Override
public boolean matches(RelOptRuleCall call) {
final ScanPrel scan = call.rel(1);
if (scan.getGroupScan().supportsFilterPushDown()) {
return super.matches(call);
}
return false;
}
@Override
public void onMatch(RelOptRuleCall call) {
final FilterPrel filterRel = call.rel(0);
final ScanPrel scanRel = call.rel(1);
doOnMatch(call, filterRel, null, scanRel);
}
};
}
use of org.apache.drill.exec.planner.physical.FilterPrel in project drill by apache.
the class FilePushDownFilter method getFilterOnProject.
public static RelOptRule getFilterOnProject(OptimizerRulesContext optimizerRulesContext) {
return new FilePushDownFilter(RelOptHelper.some(FilterPrel.class, RelOptHelper.some(ProjectPrel.class, RelOptHelper.any(ScanPrel.class))), "FilePushDownFilter:Filter_On_Project", optimizerRulesContext) {
@Override
public boolean matches(RelOptRuleCall call) {
final ScanPrel scan = call.rel(2);
if (scan.getGroupScan().supportsFilterPushDown()) {
return super.matches(call);
}
return false;
}
@Override
public void onMatch(RelOptRuleCall call) {
final FilterPrel filterRel = call.rel(0);
final ProjectPrel projectRel = call.rel(1);
final ScanPrel scanRel = call.rel(2);
doOnMatch(call, filterRel, projectRel, scanRel);
}
};
}
Aggregations