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



##########
File path: datafusion/src/physical_plan/projection.rs
##########
@@ -62,18 +61,22 @@ 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(
+            .map(|(e, name)| match input_schema.field_with_name(&name) {
+                Ok(f) => f.clone(),
+                Err(_) => Field::new(
                     name,
-                    e.data_type(&input_schema)?,
-                    e.nullable(&input_schema)?,
-                ))
+                    e.data_type(&input_schema).unwrap(),
+                    e.nullable(&input_schema).unwrap_or(true),

Review comment:
       curious what's the reason for these two unwrap changes? For 
`e.data_type`, I think it would be good to propagate the error back to the 
call. For `e.nullable(&input_schema)`, I can't think of a reason on why we want 
to default to true when looking up the corresponding expression metadata from 
input schema results an error.




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