diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs index 005bf4b98451..24fb0609b0fe 100644 --- a/datafusion/expr/src/logical_plan/plan.rs +++ b/datafusion/expr/src/logical_plan/plan.rs @@ -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` @@ -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 @@ -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]