apache / apache/datafusion

Simplify aggregate table for ordered cases

Open
#23,318 2 comments 0 reactions 1 assignee Claimed by @2010YOUY01 View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Is your feature request related to a problem or challenge?

Part of https://github.com/apache/datafusion/issues/22710
Follow up to https://github.com/apache/datafusion/pull/23309

### Describe the solution you'd like

For ordered aggregation, we can likely simplify the implementation in a similar way to #23309.

The ordered aggregation case can be split into two variants:

* **Fully ordered input**: the input is ordered by `(a, b)`, and the query groups by `(a, b)`
* **Partially ordered input**: the input is ordered by `a`, and the query groups by `(a, b)`

For the partially ordered variant, we should still use regular hash aggregation, with the early-emit optimization. For the fully ordered variant, there may be a deeper optimization that avoids the hash table entirely.

This refactor is probably easier after we first add the fast path for the fully ordered case. 🤔

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.