jkosh44 commented on code in PR #14532: URL: https://github.com/apache/datafusion/pull/14532#discussion_r1951358636
########## datafusion/functions-nested/src/remove.rs: ########## @@ -98,7 +99,7 @@ impl ScalarUDFImpl for ArrayRemove { } fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> { - Ok(arg_types[0].clone()) + Ok(coerced_fixed_size_list_to_list(&arg_types[0])) Review Comment: I don't think we should do this in this PR (or maybe ever), but if we ever did want to do this in the future, then I think the natural split would be to do coercion necessary for input arguments in `get_valid_types()` and coercion necessary for return types in `return_type()`. For example converting an array argument base type and an element type to a common type would happen in `get_valid_types()`, but converting a `FixedSizedList` to a `List` would happen in `return_type()`. If you take a look at `array_dims` as an example, it is doing something similar already in `return_type()`, https://github.com/apache/datafusion/blob/2c73fcd47ed7391c7fd34d6c593c6f0c455670d0/datafusion/functions-nested/src/dimension.rs#L98-L107 We already provide a trait function that allows functions to describe their return type as a function of their argument types, so it seems like a good place to put coercions that are needed specifically for the return type. On the other hand it adds a lot of complexity as you mentioned. The same code needs to be duplicated across all functions and the function implementer needs to actually remember to add the coercions. I just wanted to get some of my thoughts written down, but I agree that we shouldn't do any coercion in `return_type` in this PR. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org