Skip to content

Commit

Permalink
Minor: Document output schema of LogicalPlan::Aggregate and LogicalPl…
Browse files Browse the repository at this point in the history
…an::Window
  • Loading branch information
alamb committed Jan 8, 2025
1 parent b0bd899 commit 138ba89
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions datafusion/expr/src/logical_plan/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,14 @@ pub enum LogicalPlan {
/// Windows input based on a set of window spec and window
/// function (e.g. SUM or RANK). This is used to implement SQL
/// window functions, and the `OVER` clause.
///
/// See [`Window`] for more details
Window(Window),
/// Aggregates its input based on a set of grouping and aggregate
/// expressions (e.g. SUM). This is used to implement SQL aggregates
/// and `GROUP BY`.
///
/// See [`Aggregate`] for more details
Aggregate(Aggregate),
/// Sorts its input according to a list of sort expressions. This
/// is used to implement SQL `ORDER BY`
Expand Down Expand Up @@ -2365,6 +2369,19 @@ impl Filter {
}

/// Window its input based on a set of window spec and window function (e.g. SUM or RANK)
///
/// # Output Schema
///
/// The output schema is the input schema followed by the window function
/// expressions, in order.
///
/// For example, given the input schema `"A", "B", "C"` and the window function
/// `SUM(A) OVER (PARTITION BY B+1 ORDER BY C)`, the output schema will be `"A",
/// "B", "C", "SUM(A) OVER ..."` where `"SUM(A) OVER ..."` is the name of the
/// output column.
///
/// Note that the `PARTITION BY` expression "B+1" is not produced in the output
/// schema.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Window {
/// The incoming logical plan
Expand Down Expand Up @@ -2968,6 +2985,16 @@ impl PartialOrd for DistinctOn {

/// Aggregates its input based on a set of grouping and aggregate
/// expressions (e.g. SUM).
///
/// # Output Schema
///
/// The output schema is the group expressions followed by the aggregate
/// expressions in order.
///
/// For example, given the input schema `"A", "B", "C"` and the aggregate
/// `SUM(A) GROUP BY C+B`, the output schema will be `"C+B", "SUM(A)"` where
/// "C+B" and "SUM(A)" are the names of the output columns. Note that "C+B" is a
/// single new column
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
// mark non_exhaustive to encourage use of try_new/new()
#[non_exhaustive]
Expand Down

0 comments on commit 138ba89

Please sign in to comment.