Search in sources :

Example 1 with FunctionInfo

use of org.apache.asterix.om.functions.FunctionInfo in project asterixdb by apache.

the class LangExpressionToPlanTranslator method lookupBuiltinFunction.

private AbstractFunctionCallExpression lookupBuiltinFunction(String functionName, int arity, List<Mutable<ILogicalExpression>> args) {
    AbstractFunctionCallExpression f;
    FunctionIdentifier fi = new FunctionIdentifier(AlgebricksBuiltinFunctions.ALGEBRICKS_NS, functionName, arity);
    FunctionInfo afi = BuiltinFunctions.lookupFunction(fi);
    FunctionIdentifier builtinAquafi = afi == null ? null : afi.getFunctionIdentifier();
    if (builtinAquafi != null) {
        fi = builtinAquafi;
    } else {
        fi = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, functionName, arity);
        afi = BuiltinFunctions.lookupFunction(fi);
        if (afi == null) {
            return null;
        }
    }
    if (BuiltinFunctions.isBuiltinAggregateFunction(fi)) {
        f = BuiltinFunctions.makeAggregateFunctionExpression(fi, args);
    } else if (BuiltinFunctions.isBuiltinUnnestingFunction(fi)) {
        UnnestingFunctionCallExpression ufce = new UnnestingFunctionCallExpression(FunctionUtil.getFunctionInfo(fi), args);
        ufce.setReturnsUniqueValues(BuiltinFunctions.returnsUniqueValues(fi));
        f = ufce;
    } else {
        f = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(fi), args);
    }
    return f;
}
Also used : FunctionIdentifier(org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier) UnnestingFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.UnnestingFunctionCallExpression) AbstractFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression) IFunctionInfo(org.apache.hyracks.algebricks.core.algebra.functions.IFunctionInfo) FunctionInfo(org.apache.asterix.om.functions.FunctionInfo) ScalarFunctionCallExpression(org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression)

Aggregations

FunctionInfo (org.apache.asterix.om.functions.FunctionInfo)1 AbstractFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression)1 ScalarFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression)1 UnnestingFunctionCallExpression (org.apache.hyracks.algebricks.core.algebra.expressions.UnnestingFunctionCallExpression)1 FunctionIdentifier (org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier)1 IFunctionInfo (org.apache.hyracks.algebricks.core.algebra.functions.IFunctionInfo)1