alamb commented on code in PR #13756: URL: https://github.com/apache/datafusion/pull/13756#discussion_r1884568977
########## 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: Weird, when I remove this line in expr schema the test passes (with FixedSizedList): ```diff diff --git a/datafusion/expr/src/expr_schema.rs b/datafusion/expr/src/expr_schema.rs index 3317deafb..50aeb222f 100644 --- a/datafusion/expr/src/expr_schema.rs +++ b/datafusion/expr/src/expr_schema.rs @@ -152,6 +152,7 @@ impl ExprSchemable for Expr { .map(|e| e.get_type(schema)) .collect::<Result<Vec<_>>>()?; + // Verify that function is invoked with correct number and type of arguments as defined in `TypeSignature` let new_data_types = data_types_with_scalar_udf(&arg_data_types, func) .map_err(|err| { @@ -168,7 +169,7 @@ impl ExprSchemable for Expr { // Perform additional function arguments validation (due to limited // expressiveness of `TypeSignature`), then infer return type - Ok(func.return_type_from_exprs(args, schema, &new_data_types)?) + Ok(func.return_type_from_exprs(args, schema, &arg_data_types)?) } Expr::WindowFunction(window_function) => self .data_type_and_nullable_with_window_function(schema, window_function) ``` Which basically says pass the input data types directly to the function call rather than calling `data_types_with_scalar_udf` first (which claims to type coercion) https://github.com/apache/datafusion/blob/68ead283bd47de75d8aa79f6df5fe78a957df50c/datafusion/expr/src/expr_schema.rs#L171 🤔 this looks like it was added in Sep via https://github.com/apache/datafusion/commit/1b3608da7ca59d8d987804834d004e8b3e349d18 (before that the input types were passed directly) 🤔 -- 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