andygrove commented on code in PR #12308: URL: https://github.com/apache/datafusion/pull/12308#discussion_r1742798249
########## datafusion/functions/src/core/coalesce.rs: ########## @@ -60,12 +60,16 @@ impl ScalarUDFImpl for CoalesceFunc { } fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> { - Ok(arg_types[0].clone()) + Ok(arg_types + .iter() + .find_or_first(|d| !d.is_null()) + .unwrap() Review Comment: I wonder if it is ever possible for this unwrap to panic? I could trigger it by explicitly calling `return_type(&[])` but perhaps this would never happen via SQL -- 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