Search in sources :

Example 1 with MongoFilterBuilder

use of org.apache.drill.exec.store.mongo.MongoFilterBuilder in project drill by apache.

the class MongoPluginImplementor method implement.

@Override
public void implement(PluginFilterRel filter) throws IOException {
    visitChild(filter.getInput());
    LogicalExpression conditionExp = DrillOptiq.toDrill(new DrillParseContext(PrelUtil.getPlannerSettings(filter.getCluster().getPlanner())), filter.getInput(), filter.getCondition());
    MongoFilterBuilder mongoFilterBuilder = new MongoFilterBuilder(conditionExp);
    if (runAggregate) {
        Bson convertedFilterExpression = Aggregates.match(mongoFilterBuilder.parseTree()).toBsonDocument();
        operations.add(convertedFilterExpression);
    } else {
        filters = mongoFilterBuilder.parseTree();
    }
}
Also used : LogicalExpression(org.apache.drill.common.expression.LogicalExpression) MongoFilterBuilder(org.apache.drill.exec.store.mongo.MongoFilterBuilder) DrillParseContext(org.apache.drill.exec.planner.logical.DrillParseContext) Bson(org.bson.conversions.Bson)

Example 2 with MongoFilterBuilder

use of org.apache.drill.exec.store.mongo.MongoFilterBuilder 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;
}
Also used : LogicalExpression(org.apache.drill.common.expression.LogicalExpression) MongoFilterBuilder(org.apache.drill.exec.store.mongo.MongoFilterBuilder) DrillParseContext(org.apache.drill.exec.planner.logical.DrillParseContext)

Aggregations

LogicalExpression (org.apache.drill.common.expression.LogicalExpression)2 DrillParseContext (org.apache.drill.exec.planner.logical.DrillParseContext)2 MongoFilterBuilder (org.apache.drill.exec.store.mongo.MongoFilterBuilder)2 Bson (org.bson.conversions.Bson)1