RishavTiwari25 opened a new pull request, #26256: URL: https://github.com/apache/datafusion/pull/26256
## Which issue does this PR close? - Closes #25947. ## Rationale for this change `nvl` / `ifnull` change the type of their arguments: decimals become `Float64` (losing precision for large values) and timestamps and dates become `Utf8View`, so `ifnull(ts, ts) + INTERVAL '1 hour'` fails to plan. `coalesce` with the same arguments keeps the original types. `NVLFunc` wraps `CoalesceFunc` but declares `Signature::uniform(2, SUPPORTED_NVL_TYPES)`, a fixed list of boolean, integer, float and string types. Any argument type outside that list is coerced to the closest listed type before the function sees it. ## What changes are included in this PR? `NVLFunc` now uses `Signature::user_defined` and implements `coerce_types` by checking for exactly two arguments and then delegating to `CoalesceFunc::coerce_types` (`try_type_union_resolution`), so `nvl(a, b)` is typed exactly like `coalesce(a, b)`. The `SUPPORTED_NVL_TYPES` list is removed. The existing `nvl.slt` plans for int and string arguments are unchanged. ## What is the testing strategy for this PR? New cases in `datafusion/sqllogictest/test_files/nvl.slt`: `nvl` on a `DECIMAL(38,0)` keeps the full value, `arrow_typeof` of `nvl` / `ifnull` on decimal, timestamp and date arguments matches `coalesce`, `ifnull(ts, ts) + INTERVAL '1 hour'` plans and returns the shifted timestamp, and calling `nvl` with three arguments is still rejected. ## Are there any user-facing changes? `nvl` / `ifnull` return the same type as `coalesce` for the same arguments. For decimal, timestamp and date arguments this changes the result type from `Float64` / `Utf8View` to the argument type. `nvl(NULL, NULL)` now has type `Null` like `coalesce(NULL, NULL)`, where it was previously `Boolean` (the first type in the old list); the existing `nvl.slt` case is updated accordingly. I used an AI coding assistant while working on this change; I have read the diff and the tests and can walk through them. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
