Skip to content

Commit 89efc4a

Browse files
authored
Minor: Add documentation about LogicalPlan::expressions (#9698)
1 parent ad8d552 commit 89efc4a

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

datafusion/expr/src/logical_plan/extension.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ pub trait UserDefinedLogicalNode: fmt::Debug + Send + Sync {
5353
/// Return the output schema of this logical plan node.
5454
fn schema(&self) -> &DFSchemaRef;
5555

56-
/// Returns all expressions in the current logical plan node. This
57-
/// should not include expressions of any inputs (aka
58-
/// non-recursively). These expressions are used for optimizer
59-
/// passes and rewrites.
56+
/// Returns all expressions in the current logical plan node. This should
57+
/// not include expressions of any inputs (aka non-recursively).
58+
///
59+
/// These expressions are used for optimizer
60+
/// passes and rewrites. See [`LogicalPlan::expressions`] for more details.
6061
fn expressions(&self) -> Vec<Expr>;
6162

6263
/// A list of output columns (e.g. the names of columns in

datafusion/expr/src/logical_plan/plan.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,17 @@ impl LogicalPlan {
234234
])
235235
}
236236

237-
/// returns all expressions (non-recursively) in the current
238-
/// logical plan node. This does not include expressions in any
239-
/// children
237+
/// Returns all expressions (non-recursively) evaluated by the current
238+
/// logical plan node. This does not include expressions in any children
239+
///
240+
/// The returned expressions do not necessarily represent or even
241+
/// contributed to the output schema of this node. For example,
242+
/// `LogicalPlan::Filter` returns the filter expression even though the
243+
/// output of a Filter has the same columns as the input.
244+
///
245+
/// The expressions do contain all the columns that are used by this plan,
246+
/// so if there are columns not referenced by these expressions then
247+
/// DataFusion's optimizer attempts to optimize them away.
240248
pub fn expressions(self: &LogicalPlan) -> Vec<Expr> {
241249
let mut exprs = vec![];
242250
self.inspect_expressions(|e| {

0 commit comments

Comments
 (0)