xudong963 opened a new pull request, #27847: URL: https://github.com/apache/datafusion/pull/27847
## Which issue does this PR close? - Backport of #27150 to `branch-56`, for #24463. - Closes #27149 for the 56 line. ## Rationale for this change Without an `ORDER BY`, `first_value` has no `GroupsAccumulator`, so grouped aggregation keeps one boxed accumulator per group. Every `DISTINCT ON` without `ORDER BY` plans unordered `first_value`. #27150 measured 6x to 18x faster queries and up to 2.7x lower peak memory on ClickBench queries with 17.6M groups. ## What changes are included in this PR? A clean cherry-pick of #27150 (`26de352`) with `-x`. No conflicts. ## What is the testing strategy for this PR? The `first_last` unit tests from #27150 pass on this branch, as do `aggregate*.slt`, `group_by.slt` and `window*.slt`. Applied on `branch-56` together with the backports of #27021, #27547, #27732 and #26261 (opened alongside this one), the full sqllogictest suite, `cargo fmt --check` and clippy on the touched crates also pass. ## Are there any user-facing changes? No API changes. `first_value` without `ORDER BY`, including `DISTINCT ON`, is faster. The intermediate state layout is unchanged (`[first_value, is_set]`), so partial and final aggregation see the same schema as before. -- 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]
