alamb commented on issue #7142: URL: https://github.com/apache/arrow-datafusion/issues/7142#issuecomment-1808483172
> @alamb Should we introduce another Expr::ArrayFunction that differs from other Expr::ScalarFunctions? I think null handling is unique to ArrayFunction, instead of pattern matching all the array function in ScalarFunction, maybe we can just introduce a new abstraction? I don't think null handling has to be unique to array functions, and it is a complicated enough topic that adding a new abstraction I think will simply make the code even more complicated. In this case, I think the intention is to treat a NULL constant as a one element list with a single NULL I think: 1. `array_append(arg1, arg2, ...)` should accept NULL constants (which will probably come from the parser as `ScalarValue::Null`) 2. During type coercion, I expect the code to handle coercing `ScalarValue::Null` to `ScalarValue::<ElementType>)` So for the example given by @izveigor above: ``` select array_append([1, 2, 3, 4, 5], NULL); ``` I would expect this to be parsed like ``` select array_append(ScalarValue::List(<ListArray of Int32>), ScalarValue::Null); ``` Then I would expect type coercion to coerce the`Null` to be a type `Int32` (a null). ``` select array_append(ScalarValue::List(<ListArray of Int32>), ScalarValue::Int32(None)); ``` And then the function implementation only handles `ListArray` / child array of the same type (`ListArray` and `Int32Array`). The type coercion for function arguments is here: https://github.com/apache/arrow-datafusion/blob/2185842be22b695cf00e615db68b373f86fd162b/datafusion/expr/src/type_coercion/functions.rs#L33-L72 Does that make sense @jayzhan211 ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
