Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
review: more comments
  • Loading branch information
2010YOUY01 committed Jun 4, 2026
commit 3184e0044c1468a4660f5c89063253d47077b344
15 changes: 6 additions & 9 deletions datafusion/physical-plan/src/aggregates/hash_aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@
// specific language governing permissions and limitations
// under the License.

//! Grouped hash aggregation for simple multi-stage aggregation paths.
//! 2-stage hash aggregation stream implementation.
//!
//! This module handles the basic grouped two-stage paths:
//! See comments in [`InitialPartialHashAggregateStream`] and [`PartialFinalHashAggregateStream`]
//! for details.
//!
//! ```text
//! input rows -> GROUP BY hash table -> accumulator state rows
//! state rows -> GROUP BY hash table -> final aggregate rows
//! ```
//! Note these streams are an incremental migration of the existing
//! [`crate::aggregates::row_hash::GroupedHashAggregateStream`].
//!
//! `AggregateExec` keeps finite-memory, ordered, limit, grouping-set,
//! `partial state -> partial state`, and single-stage aggregation on
//! `GroupedHashAggregateStream` for now.
//! See issue for details: <https://github.com/apache/datafusion/issues/22710>

use std::sync::Arc;
use std::task::{Context, Poll};
Expand Down
27 changes: 27 additions & 0 deletions datafusion/physical-plan/src/aggregates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,39 @@ impl PartialEq for PhysicalGroupBy {
}
}

/// Streams used by [`AggregateExec`].
///
/// # Stream Variant Schema Notation
/// For example, `SELECT g, AVG(x) FROM t GROUP BY g` uses these schemas:
///
/// ```text
/// initial input: [g, x]
/// partial state: [g, AVG(x) state columns, e.g. sum/count]
/// final result: [g, AVG(x)]
/// ```
#[expect(clippy::large_enum_variant)]
enum StreamType {
/// Single group (no group by) aggregate stream.
/// Input output scheme: initial input -> final result
AggregateStream(AggregateStream),
/// Partial stage of the hash aggregation
/// Input output scheme: initial input -> partial state
InitialPartialHash(InitialPartialHashAggregateStream),
/// Final stage of the hash aggregation
/// Input output scheme: partial state -> final result
PartialFinalHash(PartialFinalHashAggregateStream),
/// Hash aggregation resused for multiple stages
///
/// Note this is being incrementally migrated to dedicated streams like
/// [`StreamType::InitialPartialHash`] and [`StreamType::PartialFinalHash`]
///
/// See issue for details: <https://github.com/apache/datafusion/issues/22710>
GroupedHash(GroupedHashAggregateStream),
/// Grouped TopK aggregate stream.
/// Input output scheme: initial input -> final result
///
/// Used for grouped aggregation with LIMIT / ordering, where the stream keeps
/// only the top groups required by the query.
GroupedPriorityQueue(GroupedTopKAggregateStream),
}

Expand Down
Loading