You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "aoto-tech (via GitHub)" <gi...@apache.org> on 2026/09/13 15:46:58 UTC
[PR] fix: avoid Float64 percentile_cont interpolation overflow [datafusion]
aoto-tech opened a new pull request, #25274:
URL: https://github.com/apache/datafusion/pull/25274
## Which issue does this PR close?
- Closes #25267.
## Rationale for this change
`percentile_cont` can return `Infinity` for finite Float64 inputs when `upper - lower` overflows, even though the interpolated result is finite. I hit this with `[-DBL_MAX, DBL_MAX]` at `0.5`; the median should be `0`.
## What changes are included in this PR?
I keep the current difference-based formula when the subtraction is finite. If both endpoints are finite but their difference overflows, I switch to weighting each endpoint separately. That avoids the infinite intermediate without changing the existing Float16 or non-finite-input paths.
I also added a direct unit test for the overflow branch with symmetric, asymmetric, and quarter-percentile cases, plus an end-to-end SQL test for the reported query.
## What is the testing strategy for this PR?
The new unit test failed with `inf != 0.0` before the fix.
I ran:
- `cargo test --profile ci -p datafusion-functions-aggregate --lib` (233 passed)
- the new `aggregate.slt` query through the sqllogictest runner (passed)
- `cargo clippy --profile ci -p datafusion-functions-aggregate --all-targets --all-features --no-deps -- -D warnings`
- `cargo fmt --all -- --check`
## Are there any user-facing changes?
Yes. `percentile_cont` now returns a finite result when finite Float64 endpoints have an overflowing difference but a finite interpolation result. There is no API change.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: avoid Float64 percentile_cont interpolation overflow [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed pull request #25274: fix: avoid Float64 percentile_cont interpolation overflow
URL: https://github.com/apache/datafusion/pull/25274
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: avoid Float64 percentile_cont interpolation overflow [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on PR #25274:
URL: https://github.com/apache/datafusion/pull/25274#issuecomment-6061898472
I can add the tests if @aoto-tech might not have time for this
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: avoid Float64 percentile_cont interpolation overflow [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25274:
URL: https://github.com/apache/datafusion/pull/25274#issuecomment-6506165703
Thanks for the contribution! I am closing this under DataFusion's AI Dump policy.
https://datafusion.apache.org/contributor-guide/ai-policy.html#what-is-an-ai-dump-and-why-it-is-not-helpful
This has the hallmarks of AI code that was not reviewed by the author: no response to reviewer requests or two maintainer pings since September, on a PR filed the same day as its issue.
If you would like to continue, please open a focused PR in your own words that you have reviewed and understand, and we are happy to help with review.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: avoid Float64 percentile_cont interpolation overflow [datafusion]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #25274:
URL: https://github.com/apache/datafusion/pull/25274#issuecomment-5666084002
## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/25274?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 81.91%. Comparing base ([`85d4cbb`](https://app.codecov.io/gh/apache/datafusion/commit/85d4cbb0a9a885f2fd22bfdac468844446ad70d6?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`f832f61`](https://app.codecov.io/gh/apache/datafusion/commit/f832f61f7b9ee7bd7df73399d558e22313df7a05?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #25274 +/- ##
=======================================
Coverage 81.91% 81.91%
=======================================
Files 1134 1134
Lines 425631 425653 +22
Branches 425631 425653 +22
=======================================
+ Hits 348647 348667 +20
Misses 56304 56304
- Partials 20680 20682 +2
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/25274?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: avoid Float64 percentile_cont interpolation overflow [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #25274:
URL: https://github.com/apache/datafusion/pull/25274#discussion_r4158546650
##########
datafusion/sqllogictest/test_files/aggregate.slt:
##########
@@ -1190,6 +1190,17 @@ FROM distinct_pct_nulls ORDER BY id;
statement ok
DROP TABLE distinct_pct_nulls;
+# Regression test for https://github.com/apache/datafusion/issues/25267
+# The finite endpoints have an overflowing difference, but their median is finite.
+query R
+SELECT percentile_cont(x, 0.5)
Review Comment:
hi @aoto-tech -- do you have time to address @kosiew 's comments?
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: avoid Float64 percentile_cont interpolation overflow [datafusion]
Posted by "kosiew (via GitHub)" <gi...@apache.org>.
kosiew commented on code in PR #25274:
URL: https://github.com/apache/datafusion/pull/25274#discussion_r4103496179
##########
datafusion/sqllogictest/test_files/aggregate.slt:
##########
@@ -1190,6 +1190,17 @@ FROM distinct_pct_nulls ORDER BY id;
statement ok
DROP TABLE distinct_pct_nulls;
+# Regression test for https://github.com/apache/datafusion/issues/25267
+# The finite endpoints have an overflowing difference, but their median is finite.
+query R
+SELECT percentile_cont(x, 0.5)
Review Comment:
Could you also add a window-function test with these extreme endpoints? It uses the same interpolation code, and this would check that the window path returns the expected result too.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: avoid Float64 percentile_cont interpolation overflow [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25274:
URL: https://github.com/apache/datafusion/pull/25274#issuecomment-6350053319
Waiting to address feedback, marking as draft until that is done to clean up our PR queue
This looks like it may be apandoned / was AI spam perhaps
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org