Search in sources :

Example 1 with FunctionKind

use of io.prestosql.spi.function.FunctionKind in project hetu-core by openlookeng.

the class FunctionResolver 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(io.prestosql.spi.type.Type) TypeSignature.parseTypeSignature(io.prestosql.spi.type.TypeSignature.parseTypeSignature) Signature(io.prestosql.spi.function.Signature) LiteralEncoder.getMagicLiteralFunctionSignature(io.prestosql.sql.planner.LiteralEncoder.getMagicLiteralFunctionSignature) FunctionKind(io.prestosql.spi.function.FunctionKind)

Aggregations

FunctionKind (io.prestosql.spi.function.FunctionKind)1 Signature (io.prestosql.spi.function.Signature)1 Type (io.prestosql.spi.type.Type)1 TypeSignature.parseTypeSignature (io.prestosql.spi.type.TypeSignature.parseTypeSignature)1 LiteralEncoder.getMagicLiteralFunctionSignature (io.prestosql.sql.planner.LiteralEncoder.getMagicLiteralFunctionSignature)1