mesejo opened a new issue, #12307: URL: https://github.com/apache/datafusion/issues/12307
### Describe the bug This [issue](https://github.com/apache/datafusion-python/issues/534) was first reported in datafusion-python; upon further inspection, this appears to be a bug in datafusion itself. ### To Reproduce This fails: ```rust async fn test_coalesce_schema() -> Result<()> { let ctx = SessionContext::new(); let query = r#"SELECT COALESCE(null, 5)"#; let result = ctx.sql(query).await?; assert_logical_expr_schema_eq_physical_expr_schema(result).await?; Ok(()) } ``` ### Expected behavior The code should not fail. ### Additional context The problem seems to be in the `ScalarUDFImpl` for `CoalesceFunc`: ```rust fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> { Ok(arg_types[0].clone()) } // If all the element in coalesce is non-null, the result is non-null fn is_nullable(&self, args: &[Expr], schema: &dyn ExprSchema) -> bool { args.iter().any(|e| e.nullable(schema).ok().unwrap_or(true)) } ``` The `return_type` is the first one when it should be the first non-null, and `is_nullable` returns true if any of the `args` is null -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
