andygrove commented on code in PR #3209:
URL: https://github.com/apache/arrow-datafusion/pull/3209#discussion_r950506661


##########
datafusion/sql/src/planner.rs:
##########
@@ -189,8 +191,14 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
                 query,
                 with_options,
                 ..
-            } if columns.is_empty() && with_options.is_empty() => {
-                let plan = self.query_to_plan(*query, &mut HashMap::new())?;
+            } if with_options.is_empty() => {
+                let columns = if columns.is_empty() {
+                    None
+                } else {
+                    Some(columns)
+                };
+                let plan =
+                    self.query_to_plan(*query, &mut HashMap::new(), 
columns.as_ref())?;

Review Comment:
   Yes, that's exactly what I'm suggesting. I think that `query_to_plan` is 
returning a valid plan for the query that is the input to the `CREATE VIEW` 
already. It seems appropriate that the code that is specific to creating the 
view should take care of adding the additional projection.



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