SEPURI-SAI-KRISHNA commented on issue #12612:
URL: https://github.com/apache/seatunnel/issues/12612#issuecomment-6163623816

   @SEZ9 correcting myself on the third point from my 2026-10-04 comment, 
before I leave a promise open that should not be kept.
   
   I said I would open a separate issue for `COALESCE` and `IFNULL` inferring 
their result type from the first non-null argument rather than the widest, and 
you agreed that was the right call. **I am withdrawing that, because it is not 
a defect.** That behaviour was requested, implemented and shipped.
   
   The evidence:
   
   - #9295, *"[Feature][SQL function] Enhance SQL Transform COALESCE functions 
to support type cast"*, asks for exactly this: *"The COALESCE function should 
automatically handle type conversion, converting any other type to args0 type 
output."*
   - It was implemented by #9299 and closed on 2025-08-20.
   - Commit `7f756b188` from that PR added both halves of what I was going to 
report: the `coalesce(args, targetType)` overload in `SystemFunction`, and the 
first-non-null walk in `ZetaSQLType` (now lines 478-490 on `dev` at 
`25bcc53fd`).
   
   So "first argument wins" is the intended contract, not an oversight, and an 
issue proposing the widest-type rule would be asking to revert a completed 
feature rather than reporting a bug. I should have checked that before 
describing it as something to fix. My description of the mechanism was 
accurate; my framing of it as a gap was not.
   
   Two things follow, and neither needs an issue:
   
   1. A user who wants the widest type can write the cast explicitly, as 
`COALESCE(CAST(int_col AS BIGINT), bigint_col)`.
   2. The consequence that does matter is already documented rather than left 
implicit. Because the target type is inferred from the first argument, 
`COALESCE` and `IFNULL` are the route by which a value reaches a narrower 
integral target with no cast written, so the range checks from #12605 and from 
the `BIGINT` change now surface there. Both `incompatible-changes.md` entries 
say so directly, and the `BIGINT` one states that this is the only route that 
reaches that conversion at all.
   
   Nothing else from that comment changes. The `BIGINT` work is ready and goes 
up as soon as #12605 lands, as described above.
   


-- 
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]

Reply via email to