Search in sources :

Example 1 with FunctionKind

use of com.facebook.presto.spi.function.FunctionKind in project presto by prestodb.

the class FunctionSignatureMatcher method returnsNullOnGivenInputTypes.

private static boolean returnsNullOnGivenInputTypes(ApplicableFunction applicableFunction, List<Type> parameterTypes) {
    Signature boundSignature = applicableFunction.getBoundSignature();
    FunctionKind functionKind = boundSignature.getKind();
    // Window and Aggregation functions have fixed semantic where NULL values are always skipped
    if (functionKind != SCALAR) {
        return true;
    }
    for (int i = 0; i < parameterTypes.size(); i++) {
        Type parameterType = parameterTypes.get(i);
        if (parameterType.equals(UNKNOWN)) {
            // to SQL spec. So there is a loss of precision here.
            if (applicableFunction.isCalledOnNullInput()) {
                return false;
            }
        }
    }
    return true;
}
Also used : Type(com.facebook.presto.common.type.Type) Signature(com.facebook.presto.spi.function.Signature) FunctionKind(com.facebook.presto.spi.function.FunctionKind)

Aggregations

Type (com.facebook.presto.common.type.Type)1 FunctionKind (com.facebook.presto.spi.function.FunctionKind)1 Signature (com.facebook.presto.spi.function.Signature)1