This is an automated email from the ASF dual-hosted git repository.
github-bot 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 bdcfd43129 Keep aggregate udaf schema names unique when missing an
order-by (#17731)
bdcfd43129 is described below
commit bdcfd431295af1317e1bab92939c25b26173d637
Author: wiedld <[email protected]>
AuthorDate: Thu Sep 25 18:17:00 2025 +0300
Keep aggregate udaf schema names unique when missing an order-by (#17731)
* test: reproducer of bug
* fix: make schema names unique for approx_percentile_cont
* test: regression test is now resolved
---
datafusion/expr/src/udaf.rs | 2 +-
datafusion/sqllogictest/test_files/aggregate.slt | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/datafusion/expr/src/udaf.rs b/datafusion/expr/src/udaf.rs
index 0279c671a7..fa71a76c09 100644
--- a/datafusion/expr/src/udaf.rs
+++ b/datafusion/expr/src/udaf.rs
@@ -805,7 +805,7 @@ pub fn udaf_default_schema_name<F: AggregateUDFImpl +
?Sized>(
// exclude the first function argument(= column) in ordered set aggregate
function,
// because it is duplicated with the WITHIN GROUP clause in schema name.
- let args = if func.is_ordered_set_aggregate() {
+ let args = if func.is_ordered_set_aggregate() && !order_by.is_empty() {
&args[1..]
} else {
&args[..]
diff --git a/datafusion/sqllogictest/test_files/aggregate.slt
b/datafusion/sqllogictest/test_files/aggregate.slt
index 4601d595e3..888b425c7a 100644
--- a/datafusion/sqllogictest/test_files/aggregate.slt
+++ b/datafusion/sqllogictest/test_files/aggregate.slt
@@ -1835,6 +1835,29 @@ c 122
d 124
e 115
+
+# using approx_percentile_cont on 2 columns with same signature
+query TII
+SELECT c1, approx_percentile_cont(c2, 0.95) AS c2, approx_percentile_cont(c3,
0.95) AS c3 FROM aggregate_test_100 GROUP BY 1 ORDER BY 1
+----
+a 5 73
+b 5 68
+c 5 122
+d 5 124
+e 5 115
+
+# error is unique to this UDAF
+query TRR
+SELECT c1, avg(c2) AS c2, avg(c3) AS c3 FROM aggregate_test_100 GROUP BY 1
ORDER BY 1
+----
+a 2.857142857143 -18.333333333333
+b 3.263157894737 -5.842105263158
+c 2.666666666667 -1.333333333333
+d 2.444444444444 25.444444444444
+e 3 40.333333333333
+
+
+
query TI
SELECT c1, approx_percentile_cont(0.95) WITHIN GROUP (ORDER BY c3 DESC) AS
c3_p95 FROM aggregate_test_100 GROUP BY 1 ORDER BY 1
----
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]