Search in sources :

Example 1 with QueryCondition

use of org.ojai.store.QueryCondition in project drill by apache.

the class JsonScanSpec method mergeScanSpec.

public void mergeScanSpec(String functionName, JsonScanSpec scanSpec) {
    if (this.condition != null && scanSpec.getCondition() != null) {
        QueryCondition newCond = MapRDB.newCondition();
        switch(functionName) {
            case "booleanAnd":
                newCond.and();
                break;
            case "booleanOr":
                newCond.or();
                break;
            default:
                assert (false);
        }
        newCond.condition(this.condition).condition(scanSpec.getCondition()).close().build();
        this.condition = newCond;
    } else if (scanSpec.getCondition() != null) {
        this.condition = scanSpec.getCondition();
    }
}
Also used : QueryCondition(org.ojai.store.QueryCondition)

Example 2 with QueryCondition

use of org.ojai.store.QueryCondition in project drill by apache.

the class JsonConditionBuilder method createJsonScanSpec.

private JsonScanSpec createJsonScanSpec(FunctionCall call, CompareFunctionsProcessor processor) {
    String functionName = processor.getFunctionName();
    SchemaPath field = processor.getPath();
    Value fieldValue = processor.getValue();
    QueryCondition cond = null;
    switch(functionName) {
        case "equal":
            cond = MapRDB.newCondition();
            setIsCondition(cond, field.getAsUnescapedPath(), Op.EQUAL, fieldValue);
            cond.build();
            break;
        case "not_equal":
            cond = MapRDB.newCondition();
            setIsCondition(cond, field.getAsUnescapedPath(), Op.NOT_EQUAL, fieldValue);
            cond.build();
            break;
        case "less_than":
            cond = MapRDB.newCondition();
            setIsCondition(cond, field.getAsUnescapedPath(), Op.LESS, fieldValue);
            cond.build();
            break;
        case "less_than_or_equal_to":
            cond = MapRDB.newCondition();
            setIsCondition(cond, field.getAsUnescapedPath(), Op.LESS_OR_EQUAL, fieldValue);
            cond.build();
            break;
        case "greater_than":
            cond = MapRDB.newCondition();
            setIsCondition(cond, field.getAsUnescapedPath(), Op.GREATER, fieldValue);
            cond.build();
            break;
        case "greater_than_or_equal_to":
            cond = MapRDB.newCondition();
            setIsCondition(cond, field.getAsUnescapedPath(), Op.GREATER_OR_EQUAL, fieldValue);
            cond.build();
            break;
        case "isnull":
            cond = MapRDB.newCondition().notExists(field.getAsUnescapedPath()).build();
            break;
        case "isnotnull":
            cond = MapRDB.newCondition().exists(field.getAsUnescapedPath()).build();
            break;
        case "istrue":
            cond = MapRDB.newCondition().is(field.getAsUnescapedPath(), Op.EQUAL, true).build();
            break;
        case "isnotfalse":
            cond = MapRDB.newCondition().is(field.getAsUnescapedPath(), Op.NOT_EQUAL, false).build();
            break;
        case "isfalse":
            cond = MapRDB.newCondition().is(field.getAsUnescapedPath(), Op.EQUAL, false).build();
            break;
        case "isnottrue":
            cond = MapRDB.newCondition().is(field.getAsUnescapedPath(), Op.NOT_EQUAL, true).build();
            break;
        case "like":
            cond = MapRDB.newCondition().like(field.getAsUnescapedPath(), fieldValue.getString()).build();
            break;
        default:
    }
    if (cond != null) {
        return new JsonScanSpec(groupScan.getTableName(), cond);
    }
    return null;
}
Also used : SchemaPath(org.apache.drill.common.expression.SchemaPath) Value(org.ojai.Value) QueryCondition(org.ojai.store.QueryCondition)

Aggregations

QueryCondition (org.ojai.store.QueryCondition)2 SchemaPath (org.apache.drill.common.expression.SchemaPath)1 Value (org.ojai.Value)1