alamb commented on a change in pull request #1088:
URL: https://github.com/apache/arrow-datafusion/pull/1088#discussion_r725472806
##########
File path: datafusion/src/optimizer/projection_push_down.rs
##########
@@ -417,9 +416,15 @@ fn optimize_plan(
})
.collect::<Result<Vec<_>>>()?;
+ let mut new_schema = Vec::new();
+ for df_field in schema.fields() {
+ if union_required_fields.contains(df_field.field()) {
+ new_schema.push(df_field.clone());
+ }
+ }
Review comment:
Yeah it took me a while to become comfortable with the functional style.
As an aside - I also later realized that using this functional style is more
than just about code structure / readability -- it is one of the key ways Rust
does fast and safe: in the `mut Vec<..>` version, every time data is pushed the
capacity of the vec needs to be checked and extended if not large enough. In
the `iter()` version often the Vec can be created up front and then written
directly into.
--
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]