alamb commented on code in PR #13756: URL: https://github.com/apache/datafusion/pull/13756#discussion_r1887033962
########## datafusion/functions-nested/src/extract.rs: ########## @@ -993,3 +993,84 @@ where let data = mutable.freeze(); Ok(arrow::array::make_array(data)) } + +#[cfg(test)] +mod tests { + use super::array_element_udf; + use arrow_schema::{DataType, Field}; + use datafusion_common::{Column, DFSchema, ScalarValue}; + use datafusion_expr::expr::ScalarFunction; + use datafusion_expr::{cast, Expr, ExprSchemable}; + use std::collections::HashMap; + + #[test] + fn test_array_element_return_type() { + let complex_type = DataType::FixedSizeList( Review Comment: > in a logical plan, the function arguments should already be of the right coerced type, we should just use them. This is perhaps the key distinction -- should get_expr_type be applying coercion rules? Or should we insist that the caller applies coercion rules first before calling ExprSchema? I can see arguments both way and I don't have a super strong preference. I don't know the context of why we needed to apply coercion rules in the first place (maybe there is some better way to achieve the goal) For this particular issue, btw, perhaps we want to address why applying the coercion rules changes the input type in the first place (which seems suspicious). Maybe it is driven based on the declared signature of [`ArrayAndIndex`](https://github.com/apache/datafusion/blob/668984e9c73c21e7fca204f818ce613bd3d90d4d/datafusion/functions-nested/src/extract.rs#L92) but I did not investigate further, -- 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