use of org.apache.drill.exec.planner.logical.DrillParseContext in project drill by apache.
the class InfoSchemaPushFilterIntoRecordGenerator method doMatch.
protected void doMatch(RelOptRuleCall call, ScanPrel scan, ProjectPrel project, FilterPrel filter) {
RexNode condition = filter.getCondition();
InfoSchemaGroupScan groupScan = (InfoSchemaGroupScan) scan.getGroupScan();
if (groupScan.isFilterPushedDown()) {
return;
}
LogicalExpression conditionExp = DrillOptiq.toDrill(new DrillParseContext(PrelUtil.getPlannerSettings(call.getPlanner())), project != null ? project : scan, condition);
InfoSchemaFilterBuilder filterBuilder = new InfoSchemaFilterBuilder(conditionExp);
InfoSchemaFilter infoSchemaFilter = filterBuilder.build();
if (infoSchemaFilter == null) {
// no filter push down ==> No transformation.
return;
}
InfoSchemaGroupScan newGroupsScan = new InfoSchemaGroupScan(groupScan.getTable(), infoSchemaFilter);
RelNode input = new ScanPrel(scan.getCluster(), filter.getTraitSet(), newGroupsScan, scan.getRowType(), scan.getTable());
if (project != null) {
input = project.copy(project.getTraitSet(), input, project.getProjects(), filter.getRowType());
}
if (filterBuilder.isAllExpressionsConverted()) {
// Filter can be removed as all expressions in the filter are converted and pushed to scan
call.transformTo(input);
} else {
call.transformTo(filter.copy(filter.getTraitSet(), ImmutableList.of(input)));
}
}
Aggregations