kosiew commented on code in PR #27799:
URL: https://github.com/apache/datafusion/pull/27799#discussion_r4780793189
##########
datafusion/functions-aggregate/src/percentile_cont.rs:
##########
@@ -1060,18 +1061,19 @@ where
upper: T::Native,
fraction: f64,
) -> Result<T::Native> {
- // Linear interpolation.
- // We compute a quantized interpolation weight using
`FLOAT_INTERPOLATION_PRECISION` because:
- // 1. Both values come from the input data, so (upper - lower) is
bounded by the value range
- // 2. fraction is between 0 and 1; quantizing it provides stable,
predictable results
- // 3. The result is guaranteed to be between lower_value and
upper_value (modulo cast rounding)
- // 4. Arithmetic is performed in f64 and cast back to avoid
overflowing Float16 intermediates
- let scaled = (fraction * (INTERPOLATION_PRECISION as f64)) as usize;
- let weight = scaled as f64 / (INTERPOLATION_PRECISION as f64);
-
+ // Linear interpolation with the unquantized fraction. The arithmetic
is done in f64
Review Comment:
Could we replace "exact interpolated values" in the PR summary with
"interpolates without truncating the weight to six decimal places"? Float64
rounding still applies. No code change needed.
--
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]