alamb commented on code in PR #4906:
URL: https://github.com/apache/arrow-datafusion/pull/4906#discussion_r1070269427


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -537,55 +566,36 @@ impl LogicalPlan {
         Ok(true)
     }
 
-    /// Visit all inputs, including subqueries
-    pub fn visit_all_inputs<V>(&self, visitor: &mut V) -> Result<bool, 
V::Error>
+    /// applies visitor to any subqueries in the plan
+    fn visit_subqueries<V>(&self, v: &mut V) -> Result<bool, V::Error>
     where
         V: PlanVisitor,
     {
-        for input in self.all_inputs() {
-            if !input.accept(visitor)? {
-                return Ok(false);
-            }
-        }
-
+        self.inspect_expressions(|expr| {
+            // recursively look for subqueries
+            walk_expr_down(expr, |expr| {
+                match expr {
+                    Expr::Exists { subquery, .. }
+                    | Expr::InSubquery { subquery, .. }
+                    | Expr::ScalarSubquery(subquery) => {
+                        // use a synthetic plan so the visitor sees a
+                        // LogicalPlan::Subquery (even though it is
+                        // actually a Subquery alias)
+                        let synthetic_plan = 
LogicalPlan::Subquery(subquery.clone());

Review Comment:
   while this behavior is strange it is consistent with what 
`collect_subqueries` was doing
   



-- 
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]

Reply via email to