Skip to content

Minor: Improve documentation for LogicalPlan::expressions #9698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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