alamb commented on code in PR #9913:
URL: https://github.com/apache/arrow-datafusion/pull/9913#discussion_r1555583500
##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -1079,57 +1317,178 @@ impl LogicalPlan {
}
}
+/// This macro is used to determine continuation during combined transforming
+/// traversals.
+macro_rules! handle_transform_recursion {
+ ($F_DOWN:expr, $F_CHILD:expr, $F_UP:expr) => {{
+ $F_DOWN?
+ .transform_children(|n| n.map_subqueries($F_CHILD))?
+ .transform_sibling(|n| n.map_children($F_CHILD))?
+ .transform_parent($F_UP)
+ }};
+}
+
+macro_rules! handle_transform_recursion_down {
+ ($F_DOWN:expr, $F_CHILD:expr) => {{
+ $F_DOWN?
+ .transform_children(|n| n.map_subqueries($F_CHILD))?
+ .transform_sibling(|n| n.map_children($F_CHILD))
+ }};
+}
+
+macro_rules! handle_transform_recursion_up {
+ ($SELF:expr, $F_CHILD:expr, $F_UP:expr) => {{
+ $SELF
+ .map_subqueries($F_CHILD)?
+ .transform_sibling(|n| n.map_children($F_CHILD))?
+ .transform_parent(|n| $F_UP(n))
+ }};
+}
+
impl LogicalPlan {
- /// applies `op` to any subqueries in the plan
- pub(crate) fn apply_subqueries<F>(&self, op: &mut F) -> Result<()>
- where
- F: FnMut(&Self) -> Result<TreeNodeRecursion>,
- {
- self.inspect_expressions(|expr| {
- // recursively look for subqueries
- inspect_expr_pre(expr, |expr| {
- match expr {
- Expr::Exists(Exists { subquery, .. })
- | Expr::InSubquery(InSubquery { subquery, .. })
- | Expr::ScalarSubquery(subquery) => {
- // use a synthetic plan so the collector sees a
- // LogicalPlan::Subquery (even though it is
- // actually a Subquery alias)
- let synthetic_plan =
LogicalPlan::Subquery(subquery.clone());
- synthetic_plan.apply(op)?;
- }
- _ => {}
+ pub fn visit_with_subqueries<V: TreeNodeVisitor<Node = Self>>(
Review Comment:
Docs: https://github.com/apache/arrow-datafusion/pull/9996
--
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]