alamb commented on a change in pull request #1378:
URL: https://github.com/apache/arrow-datafusion/pull/1378#discussion_r758772218



##########
File path: datafusion/src/physical_plan/projection.rs
##########
@@ -62,18 +61,21 @@ impl ProjectionExec {
     ) -> Result<Self> {
         let input_schema = input.schema();
 
-        let fields: Result<Vec<_>> = expr
+        let fields: Vec<Field> = expr
             .iter()
             .map(|(e, name)| {
-                Ok(Field::new(
-                    name,
-                    e.data_type(&input_schema)?,
-                    e.nullable(&input_schema)?,
-                ))
+                match input_schema.field_with_name(&name) {
+                    Ok(f) => f.clone(),

Review comment:
       👍  I think this will get the field level metadata 
   
   However, I think there is also [`Schema` level 
metadata](https://docs.rs/arrow/6.3.0/arrow/datatypes/struct.Schema.html#method.metadata)
 that still will not get copied over. 
   
   In order to copy that metadata, you can call `Schema::new_with_metadata` 
below rather than `Schema::new()`
   
   
https://docs.rs/arrow/6.3.0/arrow/datatypes/struct.Schema.html#method.new_with_metadata
   
   




-- 
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]


Reply via email to