`percentile_cont` truncates Float64 interpolation weights to six decimal places
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start in datafusion/functions-aggregate/src/percentile_cont.rs, especially the Float64 path around INTERPOLATION_PRECISION at lines 935–945. Run the SQL reproduction from the issue and trace how the interpolation weight is converted. Done when the query returns approximately 5e-7 instead of 0.0 for the reported input.
Written by the indexing model from the issue text.
Description
Describe the bug
I found that percentile_cont quantizes its Float64 interpolation weight in steps of 1e-6. Small nonzero weights therefore become zero, producing the lower input value instead of an interpolated result.
To Reproduce
I reproduced this on 55.1.0 and main at 9082d6b10.
SELECT percentile_cont(x, CAST(2.5e-7 AS DOUBLE))
FROM (VALUES
(CAST(0.0 AS DOUBLE)),
(CAST(1.0 AS DOUBLE)),
(CAST(2.0 AS DOUBLE))
) AS t(x);
actual: 0.0
expected: 5e-7
### Expected behavior
The rank is `(3 - 1) * 2.5e-7 = 5e-7`, so linear interpolation between `0.0` and `1.0` should return approximately `5e-7`.
### Additional context
The Float64 path converts the fraction to an integer using [`INTERPOLATION_PRECISION = 1_000_000`](https://github.com/apache/datafusion/blob/9082d6b10c29b72d56bede3d8e353d9d61fde542/datafusion/functions-aggregate/src/percentile_cont.rs#L935-L945). That truncates this weight to zero. I couldn't find an existing issue for the Float64 behavior.
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 354
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/datafusion
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/datafusion#25213 · 1 comment ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
apache/datafusion#25168 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
apache/datafusion#24998 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/datafusion#24913 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
apache/datafusion#24911 ·
All issues in apache/datafusion
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bitcoindevkit/bdk-ffi#1125 ·