comphead commented on code in PR #10405:
URL: https://github.com/apache/datafusion/pull/10405#discussion_r1593165948
##########
datafusion/optimizer/src/optimize_projections/mod.rs:
##########
@@ -251,32 +188,31 @@ fn optimize_projections(
RequiredIndicies::new().with_exprs(schema, all_exprs_iter)?;
let necessary_exprs = necessary_indices.get_required_exprs(schema);
- let aggregate_input = if let Some(input) =
- optimize_projections(&aggregate.input, config,
necessary_indices)?
- {
- input
- } else {
- aggregate.input.as_ref().clone()
- };
-
- // Simplify the input of the aggregation by adding a projection so
- // that its input only contains absolutely necessary columns for
- // the aggregate expressions. Note that necessary_indices refer to
- // fields in `aggregate.input.schema()`.
- let (aggregate_input, _) =
- add_projection_on_top_if_helpful(aggregate_input,
necessary_exprs)?;
-
- // Create a new aggregate plan with the updated input and only the
- // absolutely necessary fields:
- return Aggregate::try_new(
- Arc::new(aggregate_input),
- new_group_bys,
- new_aggr_expr,
- )
- .map(|aggregate| Some(LogicalPlan::Aggregate(aggregate)));
+ return optimize_projections(
+ unwrap_arc(aggregate.input),
+ config,
+ necessary_indices,
+ )?
+ .transform_data(|aggregate_input| {
+ // Simplify the input of the aggregation by adding a
projection so
+ // that its input only contains absolutely necessary columns
for
+ // the aggregate expressions. Note that necessary_indices
refer to
+ // fields in `aggregate.input.schema()`.
+ add_projection_on_top_if_helpful(aggregate_input,
necessary_exprs)
+ })?
+ .map_data(|aggregate_input| {
+ // Create a new aggregate plan with the updated input and only
the
+ // absolutely necessary fields:
+ Aggregate::try_new(
+ Arc::new(aggregate_input),
+ new_group_bys,
+ new_aggr_expr,
+ )
+ .map(LogicalPlan::Aggregate)
+ });
}
LogicalPlan::Window(window) => {
- let input_schema = window.input.schema();
+ let input_schema = window.input.schema().clone();
Review Comment:
do we need this 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]