use of org.apache.drill.exec.planner.logical.DrillParseContext in project drill by apache.
the class HBasePushFilterIntoScan method doPushFilterToScan.
protected void doPushFilterToScan(final RelOptRuleCall call, final FilterPrel filter, final ProjectPrel project, final ScanPrel scan, final HBaseGroupScan groupScan, final RexNode condition) {
final LogicalExpression conditionExp = DrillOptiq.toDrill(new DrillParseContext(PrelUtil.getPlannerSettings(call.getPlanner())), scan, condition);
final HBaseFilterBuilder hbaseFilterBuilder = new HBaseFilterBuilder(groupScan, conditionExp);
final HBaseScanSpec newScanSpec = hbaseFilterBuilder.parseTree();
if (newScanSpec == null) {
// no filter pushdown ==> No transformation.
return;
}
final HBaseGroupScan newGroupsScan = new HBaseGroupScan(groupScan.getUserName(), groupScan.getStoragePlugin(), newScanSpec, groupScan.getColumns());
newGroupsScan.setFilterPushedDown(true);
final ScanPrel newScanPrel = new ScanPrel(scan.getCluster(), filter.getTraitSet(), newGroupsScan, scan.getRowType(), scan.getTable());
// Depending on whether is a project in the middle, assign either scan or copy of project to childRel.
final RelNode childRel = project == null ? newScanPrel : project.copy(project.getTraitSet(), ImmutableList.of(newScanPrel));
if (hbaseFilterBuilder.isAllExpressionsConverted()) {
/*
* Since we could convert the entire filter condition expression into an HBase filter,
* we can eliminate the filter operator altogether.
*/
call.transformTo(childRel);
} else {
call.transformTo(filter.copy(filter.getTraitSet(), ImmutableList.of(childRel)));
}
}
use of org.apache.drill.exec.planner.logical.DrillParseContext in project drill by apache.
the class MongoPluginImplementor method canImplement.
@Override
public boolean canImplement(Filter filter) {
if (hasPluginGroupScan(filter)) {
LogicalExpression conditionExp = DrillOptiq.toDrill(new DrillParseContext(PrelUtil.getPlannerSettings(filter.getCluster().getPlanner())), filter.getInput(), filter.getCondition());
MongoFilterBuilder filterBuilder = new MongoFilterBuilder(conditionExp);
filterBuilder.parseTree();
return filterBuilder.isAllExpressionsConverted();
}
return false;
}
use of org.apache.drill.exec.planner.logical.DrillParseContext in project drill by apache.
the class PruneScanRule method materializePruneExpr.
protected LogicalExpression materializePruneExpr(RexNode pruneCondition, PlannerSettings settings, RelNode scanRel, VectorContainer container) {
// materialize the expression
logger.debug("Attempting to prune {}", pruneCondition);
final LogicalExpression expr = DrillOptiq.toDrill(new DrillParseContext(settings), scanRel, pruneCondition);
final ErrorCollectorImpl errors = new ErrorCollectorImpl();
LogicalExpression materializedExpr = ExpressionTreeMaterializer.materialize(expr, container, errors, optimizerContext.getFunctionRegistry());
// it's same as the type of output vector.
if (materializedExpr.getMajorType().getMode() == TypeProtos.DataMode.REQUIRED) {
materializedExpr = ExpressionTreeMaterializer.convertToNullableType(materializedExpr, materializedExpr.getMajorType().getMinorType(), optimizerContext.getFunctionRegistry(), errors);
}
if (errors.getErrorCount() != 0) {
logger.warn("Failure while materializing expression [{}]. Errors: {}", expr, errors);
return null;
}
return materializedExpr;
}
use of org.apache.drill.exec.planner.logical.DrillParseContext in project drill by apache.
the class FilterPrel method getPhysicalOperator.
@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
Prel child = (Prel) this.getInput();
PhysicalOperator childPOP = child.getPhysicalOperator(creator);
Filter p = new Filter(childPOP, getFilterExpression(new DrillParseContext(PrelUtil.getSettings(getCluster()))), 1.0f);
return creator.addMetadata(this, p);
}
use of org.apache.drill.exec.planner.logical.DrillParseContext in project drill by apache.
the class FlattenPrel method getPhysicalOperator.
@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
Prel child = (Prel) this.getInput();
PhysicalOperator childPOP = child.getPhysicalOperator(creator);
FlattenPOP f = new FlattenPOP(childPOP, (SchemaPath) getFlattenExpression(new DrillParseContext(PrelUtil.getSettings(getCluster()))));
return creator.addMetadata(this, f);
}
Aggregations