adriangb commented on code in PR #25838:
URL: https://github.com/apache/datafusion/pull/25838#discussion_r4140846486


##########
datafusion/optimizer/src/decorrelate.rs:
##########
@@ -170,18 +176,62 @@ impl TreeNodeRewriter for PullUpCorrelatedExpr {
                 match (self.exists_sub_query, plan_hold_outer) {
                     (false, true) => {
                         // the unsupported case
-                        self.can_pull_up = false;
-                        Ok(Transformed::new(plan, false, 
TreeNodeRecursion::Jump))
+                        Ok(self.stop_pull_up(plan))
                     }
                     _ => Ok(Transformed::no(plan)),
                 }
             }
-            _ if plan.contains_outer_reference() => {
-                // the unsupported cases, the plan expressions contain out 
reference columns(like window expressions)
-                self.can_pull_up = false;
-                Ok(Transformed::new(plan, false, TreeNodeRecursion::Jump))
+            // A correlated filter below these nodes can move above them. 
`f_up`
+            // adds the columns the pulled up filter needs to a Projection or 
an
+            // Aggregate, and checks that the filter can move above an
+            // Aggregate. A `DISTINCT` gives the same rows when a filter runs
+            // before it or after it, and its output takes the columns the node

Review Comment:
   Done: the comment now says that `DISTINCT` shares the Aggregate exemption 
and links #25808.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to