ongchi commented on code in PR #7921:
URL: https://github.com/apache/arrow-datafusion/pull/7921#discussion_r1373232186
##########
datafusion/proto/src/physical_plan/mod.rs:
##########
@@ -394,17 +394,12 @@ impl AsExecutionPlan for PhysicalPlanNode {
vec![]
};
- let input_schema = hash_agg
- .input_schema
- .as_ref()
- .ok_or_else(|| {
- DataFusionError::Internal(
- "input_schema in AggregateNode is
missing.".to_owned(),
- )
- })?
- .clone();
- let physical_schema: SchemaRef =
- SchemaRef::new((&input_schema).try_into()?);
+ let input_schema =
hash_agg.input_schema.as_ref().ok_or_else(|| {
+ DataFusionError::Internal(
+ "input_schema in AggregateNode is missing.".to_owned(),
+ )
+ })?;
+ let physical_schema: SchemaRef =
SchemaRef::new(input_schema.try_into()?);
Review Comment:
The `input_schema` here is a `&protobuf::Schema`, and the `SchemaRef` is an
alias of `Arc<physical_plan::Schema>`.
https://github.com/apache/arrow-datafusion/blob/0911f1523ec7088bae88684ecb9bca94aa553693/datafusion/proto/src/logical_plan/from_proto.rs#L372-L379
https://github.com/apache/arrow-datafusion/blob/0911f1523ec7088bae88684ecb9bca94aa553693/datafusion/proto/src/logical_plan/from_proto.rs#L609-L620
This really confusing me at first glance, it's consume a `&protobuf::Schema`
when calling `try_into()`. Seems fields will be recreated anyway, I think the
clone of `input_schema` could be eliminated.
I don't understand why these convert trait methods convert into `U` from a
`&T` rather than a `T`, this makes implicit clones in convert methods.
https://github.com/apache/arrow-datafusion/blob/0911f1523ec7088bae88684ecb9bca94aa553693/datafusion/proto/src/physical_plan/mod.rs#L490
And I just notice this line could be replaced by `physical_schema`.
--
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]