LLDay commented on code in PR #20009:
URL: https://github.com/apache/datafusion/pull/20009#discussion_r2732245481


##########
datafusion/physical-plan/src/projection.rs:
##########
@@ -485,6 +485,45 @@ impl ExecutionPlan for ProjectionExec {
                     .ok()
             })
     }
+
+    fn physical_expressions(
+        &self,
+    ) -> Option<Box<dyn Iterator<Item = Arc<dyn PhysicalExpr>> + '_>> {
+        Some(Box::new(self.projector.projection().expr_iter()))
+    }
+
+    fn with_physical_expressions(
+        &self,
+        exprs: Vec<Arc<dyn PhysicalExpr>>,
+    ) -> Result<Option<Arc<dyn ExecutionPlan>>> {
+        let expected_count = self.expr().len();
+        let exprs_count = exprs.len();
+        if exprs_count != expected_count {
+            return internal_err!(
+                "Expect {} expressions, but got {}",
+                expected_count,
+                exprs_count
+            );
+        }
+
+        let projection_exprs = self
+            .expr()
+            .iter()
+            .zip(exprs)
+            .map(|(p, expr)| ProjectionExpr::new(expr, p.alias.clone()))
+            .collect::<Vec<_>>();
+
+        let projection = ProjectionExprs::from(projection_exprs);
+        let input_schema = self.input.schema();
+        let projector = projection.make_projector(&input_schema)?;

Review Comment:
   Added the method `projection.into_projector` that consumes `self`.



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