You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/09/26 01:13:45 UTC
(datafusion) branch gh-readonly-queue/main/pr-25755-b4fd5c8ca07dc389a8d361a20423bc35bf9680e0 created (now 6a792c6713)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-25755-b4fd5c8ca07dc389a8d361a20423bc35bf9680e0
in repository https://gitbox.apache.org/repos/asf/datafusion.git
at 6a792c6713 Fix panic in `PercentileContGroupsAccumulator::convert_to_state()` (#25755)
This branch includes the following new commits:
new 6a792c6713 Fix panic in `PercentileContGroupsAccumulator::convert_to_state()` (#25755)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org
(datafusion) 01/01: Fix panic in `PercentileContGroupsAccumulator::convert_to_state()` (#25755)
Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-25755-b4fd5c8ca07dc389a8d361a20423bc35bf9680e0
in repository https://gitbox.apache.org/repos/asf/datafusion.git
commit 6a792c671376c6c91f778530220358eb70a91271
Author: Mason <ma...@coralogix.com>
AuthorDate: Sat Sep 26 01:13:32 2026 +0000
Fix panic in `PercentileContGroupsAccumulator::convert_to_state()` (#25755)
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->
- Closes #.
## Rationale for this change
`convert_to_state()` asserts that it gets a single argument, but
`percentile_cont()` is a two argument function. The assertion always
fires whenever `convert_to_state()` is called, but this was never
tested.
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
Please explain the problem you are trying to solve in terms of the
user-visible
behavior, rather than the implementation.
For example, "The code in `foo.rs` doesn't handle nulls" is a symptom of
the
implementation. "COUNT(DISTINCT) returns wrong results when the column
contains
nulls" is the user-visible problem.
-->
## What changes are included in this PR?
This change removes that assertion to be more in line with how
`update_batch()` works.
<!--
There is no need to duplicate the description in the issue here, but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
## What is the testing strategy for this PR?
I added sqllogictests that will panic without the fix here.
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
Briefly describe how this PR is tested, and point to the specific tests
you added. For example: 'This new feature is covered by the
`sqllogictest` cases added in `foo.slt`'.
If this PR does not add tests, explain why. For example, if the change
is already covered by existing tests, please mention it.
You should also check the `codecov` bot reply on this PR to confirm the
changed code is exercised.
-->
## Are there any user-facing changes?
No.
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
---
.../functions-aggregate/src/percentile_cont.rs | 4 ++--
.../test_files/aggregate_skip_partial.slt | 21 +++++++++++++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/datafusion/functions-aggregate/src/percentile_cont.rs b/datafusion/functions-aggregate/src/percentile_cont.rs
index 3dbaf40efa..5b1f6bdc1f 100644
--- a/datafusion/functions-aggregate/src/percentile_cont.rs
+++ b/datafusion/functions-aggregate/src/percentile_cont.rs
@@ -718,8 +718,8 @@ where
values: &[ArrayRef],
opt_filter: Option<&BooleanArray>,
) -> Result<Vec<ArrayRef>> {
- assert_eq!(values.len(), 1, "one argument to merge_batch");
-
+ // As in `update_batch`, only the first element holds the values; the
+ // percentile parameter and the ORDER BY columns follow it
let input_array = values[0].as_primitive::<T>();
// Directly convert the input array to states, each row will be
diff --git a/datafusion/sqllogictest/test_files/aggregate_skip_partial.slt b/datafusion/sqllogictest/test_files/aggregate_skip_partial.slt
index d659e4c836..356eb9582c 100644
--- a/datafusion/sqllogictest/test_files/aggregate_skip_partial.slt
+++ b/datafusion/sqllogictest/test_files/aggregate_skip_partial.slt
@@ -877,6 +877,27 @@ SELECT g, var(v ORDER BY i) FROM agg_order_by_t GROUP BY g ORDER BY g;
1 2
2 4
+# Test percentile_cont without WITHIN GROUP
+query IR
+SELECT g, percentile_cont(v, 0.25) FROM agg_order_by_t GROUP BY g ORDER BY g;
+----
+1 1.5
+2 6
+
+# Test percentile_cont with WITHIN GROUP
+query IR
+SELECT g, percentile_cont(0.5) WITHIN GROUP (ORDER BY v) FROM agg_order_by_t GROUP BY g ORDER BY g;
+----
+1 2
+2 7
+
+# Test percentile_cont with WITHIN GROUP and descending order
+query IR
+SELECT g, percentile_cont(0.25) WITHIN GROUP (ORDER BY v DESC) FROM agg_order_by_t GROUP BY g ORDER BY g;
+----
+1 2.5
+2 8
+
statement ok
DROP TABLE agg_order_by_t;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org