If a (simple) function is declared with NULL_IF_NULL null handling strategy (`nulls = NullHandling.NULL_IF_NULL`) there is a additional code generated which checks if any of the inputs is NULL (not set). In case if there is, output is set to be null otherwise function's code is executed and at the end output value is marked as set in case if ANY of the inputs is OPTIONAL (see https://github.com/apache/drill/blob/8edeb49873d1a1710cfe28e0b49364d07eb1aef4/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillSimpleFuncHolder.java#L143).
The problem is, this behavior makes it impossible to make output value NULL from within function's evaluation body. Which may prove useful in certain situations, e.g. when input is an empty string and output should be NULL in the case etc. Sometimes it may result in creation of two separate functions with NullHanling.INTERNAL (one for OPTIONAL and one for REQUIRED inputs) instead of one with NULL_IF_NULL. It does not follow a Principle of Least Astonishment as effectively it behaves more like "null if and only if null" and documentation for NULL_IF_NULL is as follows:
It looks as if this behavior was not intended.
Intent of this improvement is to allow output NULL values based on function's eval() method when NULL_IF_NULL null handling strategy is chosen.