jackwener commented on code in PR #4192:
URL: https://github.com/apache/arrow-datafusion/pull/4192#discussion_r1021118461


##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -1145,6 +1145,22 @@ impl Projection {
         })
     }
 
+    /// Create a new Projection using the specified output schema
+    pub fn new_from_schema(input: Arc<LogicalPlan>, schema: DFSchemaRef) -> 
Self {
+        let expr: Vec<Expr> = schema
+            .fields()
+            .iter()
+            .map(|field| field.qualified_column())
+            .map(Expr::Column)
+            .collect();
+        Self {
+            expr,
+            input,
+            schema,
+            alias: None,
+        }
+    }

Review Comment:
   Your concerns are justified. I have fixed it and added UT
   
   I noticed it before, but I forgot when I was writing the code
   
   BTW, I think we should add alias in Union, how do you think it? We should 
remove union alias, and replace with projection. @mingmwang 



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