Skip to content

Commit

Permalink
Minor: Add documentation about LogicalPlan::expressions (#9698)
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb authored Mar 20, 2024
1 parent ad8d552 commit 89efc4a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 5 additions & 4 deletions datafusion/expr/src/logical_plan/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ pub trait UserDefinedLogicalNode: fmt::Debug + Send + Sync {
/// Return the output schema of this logical plan node.
fn schema(&self) -> &DFSchemaRef;

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

/// A list of output columns (e.g. the names of columns in
Expand Down
14 changes: 11 additions & 3 deletions datafusion/expr/src/logical_plan/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,17 @@ impl LogicalPlan {
])
}

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

0 comments on commit 89efc4a

Please sign in to comment.