Skip to content

Commit 61afb0d

Browse files
authored
Minor: Document output schema of LogicalPlan::Aggregate and LogicalPlan::Window (#14047)
1 parent 5955860 commit 61afb0d

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

  • datafusion/expr/src/logical_plan

datafusion/expr/src/logical_plan/plan.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,14 @@ pub enum LogicalPlan {
215215
/// Windows input based on a set of window spec and window
216216
/// function (e.g. SUM or RANK). This is used to implement SQL
217217
/// window functions, and the `OVER` clause.
218+
///
219+
/// See [`Window`] for more details
218220
Window(Window),
219221
/// Aggregates its input based on a set of grouping and aggregate
220222
/// expressions (e.g. SUM). This is used to implement SQL aggregates
221223
/// and `GROUP BY`.
224+
///
225+
/// See [`Aggregate`] for more details
222226
Aggregate(Aggregate),
223227
/// Sorts its input according to a list of sort expressions. This
224228
/// is used to implement SQL `ORDER BY`
@@ -2365,6 +2369,19 @@ impl Filter {
23652369
}
23662370

23672371
/// Window its input based on a set of window spec and window function (e.g. SUM or RANK)
2372+
///
2373+
/// # Output Schema
2374+
///
2375+
/// The output schema is the input schema followed by the window function
2376+
/// expressions, in order.
2377+
///
2378+
/// For example, given the input schema `"A", "B", "C"` and the window function
2379+
/// `SUM(A) OVER (PARTITION BY B+1 ORDER BY C)`, the output schema will be `"A",
2380+
/// "B", "C", "SUM(A) OVER ..."` where `"SUM(A) OVER ..."` is the name of the
2381+
/// output column.
2382+
///
2383+
/// Note that the `PARTITION BY` expression "B+1" is not produced in the output
2384+
/// schema.
23682385
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
23692386
pub struct Window {
23702387
/// The incoming logical plan
@@ -2968,6 +2985,16 @@ impl PartialOrd for DistinctOn {
29682985

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

0 commit comments

Comments
 (0)