onursatici commented on code in PR #13709:
URL: https://github.com/apache/datafusion/pull/13709#discussion_r1881032088
##########
datafusion/proto/src/logical_plan/mod.rs:
##########
@@ -737,23 +737,18 @@ impl AsLogicalPlan for LogicalPlanNode {
builder.build()
}
LogicalPlanType::Union(union) => {
- let mut input_plans: Vec<LogicalPlan> = union
- .inputs
- .iter()
- .map(|i| i.try_into_logical_plan(ctx, extension_codec))
- .collect::<Result<_>>()?;
-
- if input_plans.len() < 2 {
+ if union.inputs.len() < 2 {
return Err( DataFusionError::Internal(String::from(
"Protobuf deserialization error, Union was require at
least two input.",
)));
}
+ let (first, rest) = union.inputs.split_first().unwrap();
+ let mut builder = LogicalPlanBuilder::from(
+ first.try_into_logical_plan(ctx, extension_codec)?,
+ );
- let first = input_plans.pop().ok_or_else(||
DataFusionError::Internal(String::from(
Review Comment:
I was thinking that initially, but because split_first returns a reference
to the first element, as opposed to pop, which transfers ownership, I didn't
want to clone the first plan unnecessarily
--
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]