Search in sources :

Example 6 with PushDownOptimizationException

use of org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationException in project pdi-dataservice-server-plugin by pentaho.

the class MongodbPredicate method getMongoOp.

private MongoOp getMongoOp(Condition condition) throws PushDownOptimizationException {
    validateConditionForOpDetermination(condition);
    final Condition firstChild = condition.getChildren().get(1);
    MongoOp op = MongoOp.getMongoOp(firstChild.getOperator());
    if (op == null) {
        throw new PushDownOptimizationException("Unsupported operator:  " + firstChild.getOperatorDesc());
    }
    return op;
}
Also used : Condition(org.pentaho.di.core.Condition) PushDownOptimizationException(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationException)

Example 7 with PushDownOptimizationException

use of org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationException in project pdi-dataservice-server-plugin by pentaho.

the class TableInputParameterGeneration method convertAtomicCondition.

protected String convertAtomicCondition(Condition condition, RowMeta paramsMeta, List<Object> params) throws PushDownOptimizationException {
    String value = condition.getRightExactString();
    String function = condition.getFunctionDesc();
    String placeholder = "?";
    switch(condition.getFunction()) {
        case Condition.FUNC_REGEXP:
        case Condition.FUNC_CONTAINS:
        case Condition.FUNC_STARTS_WITH:
        case Condition.FUNC_ENDS_WITH:
        case Condition.FUNC_TRUE:
            throw new PushDownOptimizationException(condition.getFunctionDesc() + " is not supported for push down.");
        case Condition.FUNC_NOT_NULL:
        case Condition.FUNC_NULL:
            placeholder = "";
            break;
        case Condition.FUNC_IN_LIST:
            Object[] inList = getInListArray(condition);
            ValueMetaInterface inListValueMeta = getResolvedValueMeta(condition);
            for (int i = 0; i < inList.length; i++) {
                paramsMeta.addValueMeta(inListValueMeta);
                params.add(inList[i]);
            }
            placeholder = String.format("(%s)", StringUtils.join(Collections.nCopies(inList.length, "?").iterator(), ","));
            function = " IN ";
            break;
        default:
            if (value == null) {
                throw new PushDownOptimizationException("Condition value can not be null: " + condition);
            }
            paramsMeta.addValueMeta(getResolvedValueMeta(condition));
            params.add(getResolvedValue(condition));
            break;
    }
    return String.format("%s %s %s", getQuotedFieldName(condition), function, placeholder);
}
Also used : PushDownOptimizationException(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

PushDownOptimizationException (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationException)7 Test (org.junit.Test)3 OptimizationImpactInfo (org.pentaho.di.trans.dataservice.optimization.OptimizationImpactInfo)3 Condition (org.pentaho.di.core.Condition)2 LinkedList (java.util.LinkedList)1 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)1 RowMeta (org.pentaho.di.core.row.RowMeta)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 ParameterGenerationTest.newCondition (org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGenerationTest.newCondition)1 StepInterface (org.pentaho.di.trans.step.StepInterface)1 TableInput (org.pentaho.di.trans.steps.tableinput.TableInput)1 TableInputMeta (org.pentaho.di.trans.steps.tableinput.TableInputMeta)1