GaneshPatil7517 commented on code in PR #19619:
URL: https://github.com/apache/datafusion/pull/19619#discussion_r2673161040


##########
datafusion/physical-plan/src/filter.rs:
##########
@@ -619,7 +686,23 @@ impl ExecutionPlan for FilterExec {
 
 impl EmbeddedProjection for FilterExec {
     fn with_projection(&self, projection: Option<Vec<usize>>) -> Result<Self> {
-        self.with_projection(projection)
+        // Check if the projection is valid
+        can_project(&self.schema(), projection.as_ref())?;
+
+        let projection = match projection {
+            Some(projection) => match &self.projection {
+                Some(p) => Some(projection.iter().map(|i| p[*i]).collect()),
+                None => Some(projection),
+            },
+            None => None,
+        };
+
+        FilterExecBuilder::new(Arc::clone(&self.predicate), 
Arc::clone(&self.input))
+            .with_projection(projection)
+            .with_default_selectivity(self.default_selectivity)
+            .with_batch_size(self.batch_size)
+            .with_fetch(self.fetch)
+            .build()

Review Comment:
   Thanks for the detailed analysis @adriangb and @nuno-faria! You're right - 
the old implementation composed projections while the new one replaces them. 
I'll update FilterExecBuilder::with_projection to compose the projections 
instead of replacing, matching the original behavior. This way we maintain 
backward compatibility while still having the cleaner builder API.



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