Skip to content

Commit fe1a9e2

Browse files
authored
Add additional docstring comments to from_plan (apache#1168)
1 parent 3c1b807 commit fe1a9e2

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

datafusion/src/optimizer/utils.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,25 @@ pub fn optimize_children(
111111
from_plan(plan, &new_exprs, &new_inputs)
112112
}
113113

114-
/// Returns a new logical plan based on the original one with inputs and expressions replaced
114+
/// Returns a new logical plan based on the original one with inputs
115+
/// and expressions replaced.
116+
///
117+
/// The exprs correspond to the same order of expressions returned by
118+
/// `LogicalPlan::expressions`. This function is used in optimizers in
119+
/// the following way:
120+
///
121+
/// ```text
122+
/// let new_inputs = optimize_children(..., plan, props);
123+
///
124+
/// // get the plans expressions to optimize
125+
/// let exprs = plan.expressions();
126+
///
127+
/// // potentially rewrite plan expressions
128+
/// let rewritten_exprs = rewrite_exprs(exprs);
129+
///
130+
/// // create new plan using rewritten_exprs in same position
131+
/// let new_plan = from_plan(&plan, rewritten_exprs, new_inputs);
132+
/// ```
115133
pub fn from_plan(
116134
plan: &LogicalPlan,
117135
expr: &[Expr],

0 commit comments

Comments
 (0)