Search in sources :

Example 1 with ComponentNotFoundException

use of org.teiid.core.ComponentNotFoundException in project teiid by teiid.

the class Evaluator method evaluate.

private Object evaluate(Function function, List<?> tuple) throws BlockedException, TeiidComponentException, ExpressionEvaluationException {
    // Get function based on resolved function info
    FunctionDescriptor fd = function.getFunctionDescriptor();
    // Evaluate args
    Expression[] args = function.getArgs();
    Object[] values = null;
    int start = 0;
    if (fd.requiresContext()) {
        values = new Object[args.length + 1];
        values[0] = context;
        start = 1;
    } else {
        values = new Object[args.length];
    }
    for (int i = 0; i < args.length; i++) {
        values[i + start] = internalEvaluate(args[i], tuple);
        if (values[i + start] instanceof Constant) {
            // $NON-NLS-1$
            throw new AssertionError("Multi-valued constant not allowed to be directly evaluated");
        }
    }
    if (fd.getPushdown() == PushDown.MUST_PUSHDOWN) {
        try {
            return evaluatePushdown(function, tuple, values);
        } catch (TeiidProcessingException e) {
            throw new ExpressionEvaluationException(e);
        }
    }
    if (fd.getProcedure() != null) {
        try {
            return evaluateProcedure(function, tuple, values);
        } catch (TeiidProcessingException e) {
            throw new ExpressionEvaluationException(e);
        }
    }
    // Check for special lookup function
    if (function.getName().equalsIgnoreCase(FunctionLibrary.LOOKUP)) {
        if (dataMgr == null) {
            throw new ComponentNotFoundException(QueryPlugin.Event.TEIID30342, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30342));
        }
        String codeTableName = (String) values[0];
        String returnElementName = (String) values[1];
        String keyElementName = (String) values[2];
        try {
            return dataMgr.lookupCodeValue(context, codeTableName, returnElementName, keyElementName, values[3]);
        } catch (TeiidProcessingException e) {
            throw new ExpressionEvaluationException(e);
        }
    }
    // Execute function
    return fd.invokeFunction(values, context, null);
}
Also used : ExpressionEvaluationException(org.teiid.api.exception.query.ExpressionEvaluationException) ComponentNotFoundException(org.teiid.core.ComponentNotFoundException) ExceptionExpression(org.teiid.query.sql.proc.ExceptionExpression) LanguageObject(org.teiid.query.sql.LanguageObject) FunctionDescriptor(org.teiid.query.function.FunctionDescriptor) TeiidProcessingException(org.teiid.core.TeiidProcessingException)

Aggregations

ExpressionEvaluationException (org.teiid.api.exception.query.ExpressionEvaluationException)1 ComponentNotFoundException (org.teiid.core.ComponentNotFoundException)1 TeiidProcessingException (org.teiid.core.TeiidProcessingException)1 FunctionDescriptor (org.teiid.query.function.FunctionDescriptor)1 LanguageObject (org.teiid.query.sql.LanguageObject)1 ExceptionExpression (org.teiid.query.sql.proc.ExceptionExpression)1