CuteChuanChuan opened a new pull request, #21988:
URL: https://github.com/apache/datafusion/pull/21988
## Which issue does this PR close?
- Closes #19536.
## Rationale for this change
`MEDIAN` over integer columns previously returned the input integer type,
which truncates the `.5` produced when averaging the two middle values of an
even-length input.
For example:
```sql
SELECT median(v) FROM (VALUES (arrow_cast(-128, 'Int8')),
(arrow_cast(127, 'Int8'))) AS t(v);
-- Old: 0 (truncated from -0.5)
-- New: -0.5
## What changes are included in this PR?
- Replace Median's Signature::numeric with Signature::one_of containing
three coercible arms:
- Decimal → preserved exactly
- Float → preserved exactly
- Integer → coerced implicitly to Float64
- Update SLT and insta snapshot expectations affected by the new return type
(column type indicators I → R, previously truncated values such as -17 → -17.5).
## Are these changes tested?
Yes. Includes:
- Existing SLT cases for median over Int8/16/32/64 and UInt8/16/32/64
- Boundary cases that previously truncated.
- insta snapshot tests.
## Are there any user-facing changes?
Yes — this is a breaking change for median(<integer_column>): Return type
changes from the input integer type to Float64.
--
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]