You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "nuno-faria (via GitHub)" <gi...@apache.org> on 2025/08/06 15:52:21 UTC
[PR] fix: string_agg not respecting ORDER BY [datafusion]
nuno-faria opened a new pull request, #17058:
URL: https://github.com/apache/datafusion/pull/17058
## 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 #17011.
## Rationale for this change
<!--
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.
-->
There was a regression in `49.0.0` in the `string_agg` function, causing it to not consider the `ORDER BY` clauses.
## What changes are included in this PR?
<!--
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.
-->
- Backported part of #16625 to version 49 (I don't think the entire PR can be backported since it appears to have breaking changes).
## Are these changes tested?
<!--
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
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
Yes.
## Are there any user-facing changes?
<!--
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.
-->
No.
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3188247152
Thanks again @nuno-faria @findepi and @berkaysynnada for getting this done for the 49.0.1 release
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3188117927
> if there is urgency to merge & release 49.0.1, i am fine if there isn't, I'd like to merge to main first.
I would like to get the 49.0.1 release candidate (as there is then still a 3 day voting period before we can release) so I will merge this one in and follow along on https://github.com/apache/datafusion/pull/17165 and try and help as possible
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "nuno-faria (via GitHub)" <gi...@apache.org>.
nuno-faria commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3167327060
> I am therefore fine with this backport in current shape. @nuno-faria can you please make sure the build is green?
@findepi The build error comes from the cherry-picked #17065, since `udf_equals_hash!` does not exist in version 49. Should we backport `udf_equals_hash!` to `49.0.1` or cancel cherry picking #17065?
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #17058:
URL: https://github.com/apache/datafusion/pull/17058
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3185659863
if there is urgency to merge & release 49.0.1, i am fine
if there isn't, I'd like to merge to main first.
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "nuno-faria (via GitHub)" <gi...@apache.org>.
nuno-faria commented on code in PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#discussion_r2262346307
##########
datafusion/functions-aggregate/src/array_agg.rs:
##########
@@ -78,12 +78,14 @@ This aggregation function can only mix DISTINCT and ORDER BY if the ordering exp
/// ARRAY_AGG aggregate expression
pub struct ArrayAgg {
signature: Signature,
+ is_input_pre_ordered: bool,
Review Comment:
I just noticed that the `udf_equals_hash!` macro is not defined in version `49`. How should we proceed?
--
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: string_agg not respecting ORDER BY [datafusion]
Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on code in PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#discussion_r2259736924
##########
datafusion/functions-aggregate/src/array_agg.rs:
##########
@@ -78,12 +78,14 @@ This aggregation function can only mix DISTINCT and ORDER BY if the ordering exp
/// ARRAY_AGG aggregate expression
pub struct ArrayAgg {
signature: Signature,
+ is_input_pre_ordered: bool,
Review Comment:
Please cherry pick https://github.com/apache/datafusion/pull/17065 as well
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "nuno-faria (via GitHub)" <gi...@apache.org>.
nuno-faria commented on code in PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#discussion_r2262314178
##########
datafusion/functions-aggregate/src/array_agg.rs:
##########
@@ -78,12 +78,14 @@ This aggregation function can only mix DISTINCT and ORDER BY if the ordering exp
/// ARRAY_AGG aggregate expression
pub struct ArrayAgg {
signature: Signature,
+ is_input_pre_ordered: bool,
Review Comment:
Done.
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3178770892
I am hoping we can make a release candidate with this fix in it today or tomorrow. Are we waiting on a PR for an alternate approach "The fix is to simply implement AggregateUDFImpl::reverse_expr for StringAgg" ?
- https://github.com/apache/datafusion/issues/17036
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "nuno-faria (via GitHub)" <gi...@apache.org>.
nuno-faria commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3182742707
> I would feel more comfortable approving a smaller PR, especially when it targets a maintenance branch.
The new fix makes the PR smaller, since it only implements `AggregateUDFImpl::reverse_expr` for `StringAgg`.
> I also recommend adding another slt test to assert the planning result. Otherwise, it’s good to go (after deciding where to land)
Updated. I think the fix should be good to go.
> BTW, how does #16217 affect this? Were you able to see that those queries used `array_agg` before, and after that PR they now use `string_agg`? I’m a bit confused about that.
They still used `string_agg`, but the `SortExec` was dropped after #16217. I just used `array_agg` as a comparison since the order on that function still worked after #16217.
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on code in PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#discussion_r2272648661
##########
datafusion/functions-aggregate/src/string_agg.rs:
##########
@@ -178,6 +178,10 @@ impl AggregateUDFImpl for StringAgg {
)))
}
+ fn reverse_expr(&self) -> datafusion_expr::ReversedUDAF {
Review Comment:
Can you please add this on `main` _**first**_?
This would make it impossible that anyone updating from 49.0.1 to a newer DF version experiences a behavioral regression.
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "nuno-faria (via GitHub)" <gi...@apache.org>.
nuno-faria commented on code in PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#discussion_r2272758795
##########
datafusion/functions-aggregate/src/string_agg.rs:
##########
@@ -178,6 +178,10 @@ impl AggregateUDFImpl for StringAgg {
)))
}
+ fn reverse_expr(&self) -> datafusion_expr::ReversedUDAF {
Review Comment:
PR open: https://github.com/apache/datafusion/pull/17165
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3167402053
I think it's best to replace usage of `udf_equals_hash` with a direct implementation of `equals` and `hash_value`, delegating to `Eq` and `Hash` that are derived on the struct.
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3167250054
> The issue comes from #16217, however I am not sure of the exact cause as that PR is very large.
I don't know either and the naive idea to revert that change on the release branch sounds much much less safe than adding a new but small feature work in lie of a bug fix.
I am therefore fine with this backport in current shape. @nuno-faria can you please make sure the build is green?
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "berkaysynnada (via GitHub)" <gi...@apache.org>.
berkaysynnada commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3172581815
> The fix is to simply implement `AggregateUDFImpl::reverse_expr` for `StringAgg`
I prefer this option. There’s no need to overwhelm operators if there wouldn’t be any benefit.
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "nuno-faria (via GitHub)" <gi...@apache.org>.
nuno-faria commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3178807313
> I am hoping we can make a release candidate with this fix in it today or tomorrow. Are we waiting on a PR for an alternate approach "The fix is to simply implement AggregateUDFImpl::reverse_expr for StringAgg" ?
>
> * [Release DataFusion `49.0.1` (patch) #17036](https://github.com/apache/datafusion/issues/17036)
I will push the alternative solution then if no one disagrees.
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3185133575
> Other than https://github.com/apache/datafusion/pull/17058/files#r2272648661, this LGTM
@findepi is it ok with you to merge this PR now, or should we wait for the forward port to main to merge first?
- https://github.com/apache/datafusion/pull/17165
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "nuno-faria (via GitHub)" <gi...@apache.org>.
nuno-faria commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3178913275
Fix pushed. It might also be worth thinking about pushing this fix to main, since currently the `SortExec` is also missing there for `string_agg`:
```sql
> create table t (k varchar, v int);
0 row(s) fetched.
Elapsed 0.005 seconds.
> insert into t values ('a', 2), ('b', 3), ('c', 1);
+-------+
| count |
+-------+
| 3 |
+-------+
1 row(s) fetched.
Elapsed 0.011 seconds.
> explain select string_agg(k, ',' order by v) from t;
+---------------+-------------------------------+
| plan_type | plan |
+---------------+-------------------------------+
| physical_plan | ┌───────────────────────────┐ |
| | │ AggregateExec │ |
| | │ -------------------- │ |
| | │ aggr: │ |
| | │ string_agg(t.k, ,) ORDER │ |
| | │ BY [t.v ASC NULLS LAST] │ |
| | │ │ |
| | │ mode: Single │ |
| | └─────────────┬─────────────┘ |
| | ┌─────────────┴─────────────┐ |
| | │ DataSourceExec │ |
| | │ -------------------- │ |
| | │ bytes: 296 │ |
| | │ format: memory │ |
| | │ rows: 1 │ |
| | └───────────────────────────┘ |
| | |
+---------------+-------------------------------+
1 row(s) fetched.
Elapsed 0.010 seconds.
> explain select array_agg(k order by v) from t;
+---------------+-------------------------------+
| plan_type | plan |
+---------------+-------------------------------+
| physical_plan | ┌───────────────────────────┐ |
| | │ AggregateExec │ |
| | │ -------------------- │ |
| | │ aggr │ |
| | │ │ |
| | │ mode: Single │ |
| | └─────────────┬─────────────┘ |
| | ┌─────────────┴─────────────┐ |
| | │ SortExec │ |
| | │ -------------------- │ |
| | │ v@1 ASC NULLS LAST │ |
| | └─────────────┬─────────────┘ |
| | ┌─────────────┴─────────────┐ |
| | │ DataSourceExec │ |
| | │ -------------------- │ |
| | │ bytes: 296 │ |
| | │ format: memory │ |
| | │ rows: 1 │ |
| | └───────────────────────────┘ |
| | |
+---------------+-------------------------------+
```
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3178927007
> Fix pushed. It might also be worth thinking about pushing this fix to main, since currently the `SortExec` is also missing there for `string_agg`:
I don't think it's imperative to implement the `reverse_expr` for string_agg on the maintenance branch. Is it required here, @berkaysynnada ?
I would feel more comfortable approving a smaller PR, especially when it targets a maintenance branch.
I am all for improving the state of things on `main`. I would prefer improvements such as adding `reverse_expr` for string_agg are reviewed and merged on `main` first, and then backported to maintenance branch.
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "berkaysynnada (via GitHub)" <gi...@apache.org>.
berkaysynnada commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3178977391
@findepi I think it's fine to fix 49.0 with this patch, as it is indeed a bug fix rather than an improvement (if anyone requests it to be fixed). Besides, this should be fixed on main as well in any case.
@nuno-faria thank you for spotting this issue. I also recommend adding another slt test to assert the planning result. Otherwise, it’s good to go (after deciding where to land)
BTW, how does #16217 affect this? Were you able to see that those queries used `array_agg` before, and after that PR they now use `string_agg`? I’m a bit confused about that.
--
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: string_agg not respecting ORDER BY [datafusion]
Posted by "nuno-faria (via GitHub)" <gi...@apache.org>.
nuno-faria commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3163376257
> Would be good to understand the source of regression #17011.
The issue comes from #16217, however I am not sure of the exact cause as that PR is very large.
> Is there a smaller & safer fix we could make in the 49 maintenance branch?
I had found that the minimum/easiest fix would be to add the `sort` method and `self.sort()` in the `execute` method, but decided to backport `is_input_pre_ordered` just in case.
--
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: string_agg not respecting ORDER BY [datafusion]
Posted by "findepi (via GitHub)" <gi...@apache.org>.
findepi commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3163346714
This PR adds new feature code.
Would be good to understand the source of regression https://github.com/apache/datafusion/issues/17011.
Is there a smaller & safer fix we could make in the 49 maintenance branch?
--
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] [branch-49] fix: string_agg not respecting ORDER BY [datafusion]
Posted by "nuno-faria (via GitHub)" <gi...@apache.org>.
nuno-faria commented on PR #17058:
URL: https://github.com/apache/datafusion/pull/17058#issuecomment-3171931826
Thanks @berkaysynnada for the pointers. I did a little more digging and found that the `get_finer_aggregate_exprs_requirement` function returns a different value for `string_agg` and `array_agg`. The source of the difference is that `AggregateUDFImpl::reverse_expr` is not defined for `string_agg`. This means the `SortExec` will not be created for `string_agg`, and that is still true in the main branch of datafusion.
```
# string_agg
| physical_plan after CombinePartialFinalAggregate | OutputRequirementExec: order_by=[], dist_by=Unspecified
| | AggregateExec: mode=Single, gby=[], aggr=[string_agg(t.k,Utf8(",")) ORDER BY [t.v ASC NULLS LAST]]
| | DataSourceExec: partitions=1, partition_sizes=[1]
| |
| physical_plan after EnforceSorting | SAME TEXT AS ABOVE
# array_agg
| physical_plan after CombinePartialFinalAggregate | OutputRequirementExec: order_by=[], dist_by=Unspecified
| | AggregateExec: mode=Single, gby=[], aggr=[array_agg(t.k) ORDER BY [t.v ASC NULLS LAST]]
| | DataSourceExec: partitions=1, partition_sizes=[1]
| |
| physical_plan after EnforceSorting | OutputRequirementExec: order_by=[], dist_by=Unspecified
| | AggregateExec: mode=Single, gby=[], aggr=[array_agg(t.k) ORDER BY [t.v ASC NULLS LAST]]
| | SortExec: expr=[v@1 ASC NULLS LAST], preserve_partitioning=[false]
| | DataSourceExec: partitions=1, partition_sizes=[1]
```
The fix is to simply implement `AggregateUDFImpl::reverse_expr` for `StringAgg`. @alamb @findepi what do you think of this approach? With it there is no need cherry pick a new feature into `49.0.1`.
--
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