jayzhan211 commented on issue #23045: URL: https://github.com/apache/datafusion/issues/23045#issuecomment-5814261594
Closing as working as intended. DataFusion follows Postgres/DuckDB here: in `COALESCE`, a string literal next to a numeric argument resolves to the numeric type, so the result type is `Int64`: ```sql SELECT coalesce(1, '5'); -- 1, Int64 SELECT coalesce(bigint_col, '0') + 1; -- numeric arithmetic works SELECT coalesce(1, ''); -- error: Cannot cast string '' to value of Int64 type ``` The last one fails because `''` isn't a valid integer, which is the same result as in Postgres. If you want a string result, cast explicitly: `coalesce(CAST(1 AS VARCHAR), '')`. Typing it as a string (#23225) would break the second query and change VALUES / `make_array` / array functions, which share the same coercion. -- 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]
