alamb commented on code in PR #10410:
URL: https://github.com/apache/datafusion/pull/10410#discussion_r1595383012


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -467,6 +468,200 @@ impl LogicalPlan {
         self.with_new_exprs(self.expressions(), inputs.to_vec())
     }
 
+    /// Recomputes schema and type information for this LogicalPlan if needed.
+    ///
+    /// Some `LogicalPlan`s may need to recompute their schema if the number or
+    /// type of expressions have been changed (for example due to type
+    /// coercion). For example [`LogicalPlan::Projection`]s schema depends on
+    /// its expressions.
+    ///
+    /// Some `LogicalPlan`s schema is unaffected by any changes to their
+    /// expressions. For example [`LogicalPlan::Filter`] schema is always the
+    /// same as its input schema.
+    ///
+    /// # Return value
+    /// Returns an error if there is some issue recomputing the schema.
+    ///
+    /// # Notes
+    ///
+    /// * Does not recursively recompute schema for input (child) plans.
+    pub fn recompute_schema(self) -> Result<Self> {

Review Comment:
   The key difference is that to use `new_with_expr` it requires providing a 
copy (`Vec<Expr>` and `Vec<LogicalPlan>`) where as this function can be used 
after modifying the Exprs (or children) via methods such as `map_children` and 
`map_expressions`
   
   Avoiding those copies is a key part of improve planning performance in PRs 
like https://github.com/apache/datafusion/pull/10356 (the change is basically 
to stop copying)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to