The type computation for COALESCE() currently falls back to VariadicFunctionValue#getResultType():
@Override
public Type getResultType() {
return children.get(0).getResultType();
}
This returns the type of the first argument. For COALESCE() that is not entirely correct because it will usually get the nullability wrong. The result type of COALESCE() is not-nullable when any argument is non-nullable. A common idiom is COALESCE(…, 0), whose result is not nullable.
Fixing this should unlock some opportunities for simplifying and constant-folding expressions containing COALESCE().
The type computation for
COALESCE()currently falls back toVariadicFunctionValue#getResultType():This returns the type of the first argument. For
COALESCE()that is not entirely correct because it will usually get the nullability wrong. The result type ofCOALESCE()is not-nullable when any argument is non-nullable. A common idiom isCOALESCE(…, 0), whose result is not nullable.Fixing this should unlock some opportunities for simplifying and constant-folding expressions containing
COALESCE().