This is an automated email from the ASF dual-hosted git repository.
jonah pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 58c70857ca Fix: approx_percentile_cont_with_weight Panic (#12823)
58c70857ca is described below
commit 58c70857ca253dda9a1b3e24b02676d4e8452ee1
Author: Jonathan Chen <[email protected]>
AuthorDate: Wed Oct 9 21:54:34 2024 -0400
Fix: approx_percentile_cont_with_weight Panic (#12823)
* Fixed NaN Error
* fmt fix
* Added guard
* Remove checks
---
datafusion/functions-aggregate-common/src/tdigest.rs | 4 +++-
datafusion/sqllogictest/test_files/aggregate.slt | 18 ++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/datafusion/functions-aggregate-common/src/tdigest.rs
b/datafusion/functions-aggregate-common/src/tdigest.rs
index 620a68e83e..e6723b54b3 100644
--- a/datafusion/functions-aggregate-common/src/tdigest.rs
+++ b/datafusion/functions-aggregate-common/src/tdigest.rs
@@ -644,7 +644,9 @@ impl TDigest {
let max = cast_scalar_f64!(&state[3]);
let min = cast_scalar_f64!(&state[4]);
- assert!(max.total_cmp(&min).is_ge());
+ if min.is_finite() && max.is_finite() {
+ assert!(max.total_cmp(&min).is_ge());
+ }
Self {
max_size,
diff --git a/datafusion/sqllogictest/test_files/aggregate.slt
b/datafusion/sqllogictest/test_files/aggregate.slt
index 250fa85cdd..54ce91b8e7 100644
--- a/datafusion/sqllogictest/test_files/aggregate.slt
+++ b/datafusion/sqllogictest/test_files/aggregate.slt
@@ -1385,6 +1385,24 @@ NaN
statement ok
DROP TABLE tmp_percentile_cont;
+# Test for issue where approx_percentile_cont_with_weight
+
+statement ok
+CREATE TABLE t1(v1 BOOL);
+
+statement ok
+INSERT INTO t1 VALUES (TRUE);
+
+# ISSUE: https://github.com/apache/datafusion/issues/12716
+# This test verifies that approx_percentile_cont_with_weight does not panic
when given 'NaN' and returns 'inf'
+query R
+SELECT approx_percentile_cont_with_weight('NaN'::DOUBLE, 0, 0) FROM t1 WHERE
t1.v1;
+----
+Infinity
+
+statement ok
+DROP TABLE t1;
+
# csv_query_cube_avg
query TIR
SELECT c1, c2, AVG(c3) FROM aggregate_test_100 GROUP BY CUBE (c1, c2) ORDER BY
c1, c2
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]