mpurins-coralogix opened a new issue, #19086:
URL: https://github.com/apache/datafusion/issues/19086
### Describe the bug
In some cases ApproxPercentileAccumulator panics when hi arg happen to be
lower than lo arg for TDigest::clamp
Example when this can happen:
```
❯ RUST_BACKTRACE=full datafusion-cli
DataFusion CLI v51.0.0
> select approx_percentile_cont(0.99) within group (order by value) from
(select 15.699999988079073 as value from generate_series(1,215));
thread 'main' (22014348) panicked at
/Users/mpurins/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/num/f64.rs:1413:9:
min > max, or either was NaN. min = 15.699999988079075, max =
15.699999988079073
stack backtrace:
0: 0x104fa171c -
<std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as
core::fmt::Display>::fmt::h616cb314f2809ae5
1: 0x104fb291c - core::fmt::write::h18ff235c5756333a
2: 0x104f79a14 - std::io::Write::write_fmt::h08b80747d0efe8cf
3: 0x104f83020 -
std::sys::backtrace::BacktraceLock::print::h96f00828e06745e0
4: 0x104f85ecc -
std::panicking::default_hook::{{closure}}::h662f695cb162c645
5: 0x104f85d80 - std::panicking::default_hook::hdc5171bc2654f38e
6: 0x104f866c4 - std::panicking::panic_with_hook::hc216de099a2fe04e
7: 0x104f863ac -
std::panicking::panic_handler::{{closure}}::hc0a7f90b1247e042
8: 0x104f83138 -
std::sys::backtrace::__rust_end_short_backtrace::he22d41b92463e575
9: 0x104f71864 - __rustc[de0091b922c53d7e]::rust_begin_unwind
10: 0x1050517d0 - core::panicking::panic_fmt::h9ec18d20141b7425
11: 0x105050fdc - core::f64::<impl
f64>::clamp::do_panic::runtime::h4890885dd7724ff7
12: 0x103901d94 -
datafusion_functions_aggregate_common::tdigest::TDigest::estimate_quantile::h41f5b5cfa69805cf
13: 0x102e14294 -
<datafusion_functions_aggregate::approx_percentile_cont::ApproxPercentileAccumulator
as
datafusion_expr_common::accumulator::Accumulator>::evaluate::hf3e2ad20d4d4a45c
14: 0x1028e4584 - <core::iter::adapters::map::Map<I,F> as
core::iter::traits::iterator::Iterator>::try_fold::h7ed9527332c74a7f
15: 0x10289e7c0 - <alloc::vec::Vec<T> as
alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter::he877276b543ed9f6
16: 0x102a4917c -
core::iter::adapters::try_process::h89d89571eacd8dd6
17: 0x1028a12d8 - <futures_util::stream::unfold::Unfold<T,F,Fut> as
futures_core::stream::Stream>::poll_next::h9e2e832f95d7f22d
18: 0x102a3b7b0 - <futures_util::stream::stream::fuse::Fuse<S> as
futures_core::stream::Stream>::poll_next::he052d17a3074693c
19: 0x100ecee78 -
datafusion_cli::exec::exec_and_print::{{closure}}::hb32729059f77c12c
20: 0x100ef81dc - <core::future::poll_fn::PollFn<F> as
core::future::future::Future>::poll::h7a1d3bd4613693fb
21: 0x100e65534 -
datafusion_cli::main_inner::{{closure}}::h9cd9904ca29a9554
22: 0x100e6dc90 -
datafusion_cli::main::{{closure}}::ha77c2a6086bf3d00
23: 0x100eb8418 -
tokio::runtime::park::CachedParkThread::block_on::ha1d171ac48cf85c5
24: 0x100e918b0 -
tokio::runtime::runtime::Runtime::block_on::h7ee4d8f507b1e4da
25: 0x100eff95c - datafusion_cli::main::hf6585ab65f6712f1
26: 0x100dfe318 -
std::sys::backtrace::__rust_begin_short_backtrace::h954b183a227018e8
27: 0x100e24d60 -
std::rt::lang_start::{{closure}}::h6e080d9484671413
28: 0x104f7b624 - std::rt::lang_start_internal::h7e788da8c79e20dc
29: 0x100f3bc18 - _main
```
### To Reproduce
Run following query in datafusion-cli
```
select approx_percentile_cont(0.99) within group (order by value) from
(select 15.699999988079073 as value from generate_series(1,215));
```
### Expected behavior
_No response_
### Additional context
_No response_
--
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]