LLDay commented on code in PR #20009:
URL: https://github.com/apache/datafusion/pull/20009#discussion_r2738532115
##########
datafusion/physical-plan/src/projection.rs:
##########
@@ -485,6 +487,44 @@ 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,
+ params: ReplacePhysicalExpr,
+ ) -> Result<Option<Arc<dyn ExecutionPlan>>> {
+ let expected_count = self.expr().len();
+ let exprs_count = params.exprs.len();
+ assert_eq_or_internal_err!(
+ expected_count,
+ exprs_count,
+ "Inconsistent number of physical expressions for {}",
+ self.name()
+ );
+
+ let projection_exprs = self
+ .expr()
+ .iter()
+ .zip(params.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.into_projector(&input_schema)?;
+
+ Ok(Some(Arc::new(Self {
+ projector,
+ input: Arc::clone(&self.input),
+ metrics: ExecutionPlanMetricsSet::new(),
+ cache: self.cache.clone(),
+ })))
Review Comment:
I applied these changes where possible (some execution plans do not
implement clone).
--
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]