> select to_date('2019-01-12', `expr$0`) from (values ('yyyy-mm-dd'));
Error: SYSTEM ERROR: CompileException: Line 87, Column 32: Expression "right.end" is not an rvalue
I am deeply confused by the assumption of the UDF framework. Take simple functions for example, it has 'setup()' and 'eval()' methods. It seems that 'setup()' is meant to handle some immutable input and state across the entire table processing, and 'eval()' to handle state/output related to each row.
However there are several problems:
- The codegen would only generate argument reference for 'setup()' if the argument is a Constant (a runtime check). However if this is the case, then the check should not be a runtime check, it should be an annotation such as @Param(constant=true). Otherwise when users pass in a column reference instead of a constant, the above error occurs.
- a NULL_IF_NULL simple functions could leave the null handling to the framework, so that it can focus on the situation where arguments are non-null. However the null handling code covers only 'eval()' function, it does not cover the 'setup()' function. Which might lead to problem when the argument is a constant OPTIONAL type (though it seems odd, it's possible when using a CASE WHEN expression)
- UDF with Nullable parameters should be able to accept arguments of REQUIRED type. However current code of function resolving does not support such cases.
Could someone please share more information about the UDF framework and the future development direction of it? Such as:
- What's the purpose of the 'setup()' method, and should it refer to non-constant parameters?
- Should a REQUIRED argument be accepted as a OPTIONAL parameter?
Thank you very much.