Jiashu-Hu commented on code in PR #15142:
URL: https://github.com/apache/datafusion/pull/15142#discussion_r1989981505


##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -774,11 +774,19 @@ impl OptimizerRule for PushDownFilter {
 
         let plan_schema = Arc::clone(plan.schema());
 
-        let LogicalPlan::Filter(mut filter) = plan else {
+        let LogicalPlan::Filter(mut filter) = plan.clone() else {
             return Ok(Transformed::no(plan));
         };
 
         match Arc::unwrap_or_clone(filter.input) {
+            // This prevents the Filter from being removed when the extension 
node has no children,
+            // so we return the original Filter unchanged.
+            LogicalPlan::Extension(extension_plan)
+                if extension_plan.node.inputs().is_empty() =>
+            {
+                filter.input = 
Arc::new(LogicalPlan::Extension(extension_plan));
+                Ok(Transformed::no(LogicalPlan::Filter(filter)))
+            }

Review Comment:
   Yes, we can absolutely do that. I will do it later today. Thank you very 
much for your review!



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