aoto-tech opened a new issue, #25267:
URL: https://github.com/apache/datafusion/issues/25267

   ### Describe the bug
   
   I found that `percentile_cont` can return infinity for finite Float64 inputs 
even when the interpolated result is finite.
   
   ### To Reproduce
   
   I reproduced this on 55.1.0 and `main` at `9082d6b10`.
   
   ```sql
   SELECT percentile_cont(x, CAST(0.5 AS DOUBLE))
   FROM (VALUES
     (CAST(-1.7976931348623157e308 AS DOUBLE)),
     (CAST( 1.7976931348623157e308 AS DOUBLE))
   ) AS t(x);
   ```
   
   ```text
   actual:   Infinity
   expected: 0.0
   
   ### Expected behavior
   
   The median of `-DBL_MAX` and `DBL_MAX` should be `0.0`.
   
   ### Additional context
   
   The Float64 interpolation path evaluates [`lower + (upper - lower) * 
weight`](https://github.com/apache/datafusion/blob/9082d6b10c29b72d56bede3d8e353d9d61fde542/datafusion/functions-aggregate/src/percentile_cont.rs#L943-L945).
 `upper - lower` overflows before multiplication by `0.5`.
   
   This is separate from #18945: that issue fixed Float16 interpolation by 
widening it to Float64, while this reproducer overflows in Float64 itself. I 
couldn't find an existing issue for this behavior.
   


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

Reply via email to