peter-toth commented on code in PR #9913:
URL: https://github.com/apache/arrow-datafusion/pull/9913#discussion_r1550241162
##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -1080,8 +1298,72 @@ impl LogicalPlan {
}
impl LogicalPlan {
+ pub fn apply_with_subqueries<F: FnMut(&Self) -> Result<TreeNodeRecursion>>(
+ &self,
+ f: &mut F,
+ ) -> Result<TreeNodeRecursion> {
+ // Compared to the default implementation, we need to invoke
+ // [`Self::apply_subqueries`] before visiting its children
+ handle_visit_recursion!(f(self)?, DOWN);
+ self.apply_subqueries(f)?;
+ self.apply_children(&mut |n| n.apply_with_subqueries(f))
+ }
+
+ pub fn visit_with_subqueries<V: TreeNodeVisitor<Node = Self>>(
+ &self,
+ visitor: &mut V,
+ ) -> Result<TreeNodeRecursion> {
+ // Compared to the default implementation, we need to invoke
+ // [`Self::visit_subqueries`] before visiting its children
+ match visitor.f_down(self)? {
+ TreeNodeRecursion::Continue => {
+ self.visit_subqueries(visitor)?;
+ handle_visit_recursion!(
+ self.apply_children(&mut |n|
n.visit_with_subqueries(visitor))?,
+ UP
+ );
+ visitor.f_up(self)
+ }
+ TreeNodeRecursion::Jump => {
+ self.visit_subqueries(visitor)?;
Review Comment:
I just moved the code here from `LogicalPlan::visit()` and in this PR I
didn't want to change how subqueries are handled. The new code I added in
`LogicalPlan::rewrite_with_subqueries()` are in sync with this behaviour.
But this is a good question and I think you are right and I too would treat
them as additional children. But that would be an API behavior change so I
would rather change that in a separate PR.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]