Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16233#discussion_r94688532
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -658,6 +748,24 @@ class Analyzer(
               Generate(newG.asInstanceOf[Generator], join, outer, qualifier, 
output, child)
             }
     
    +      // A special case for View, replace the output attributes with the 
attributes that have the
    +      // same names from the child. If the corresponding attribute is not 
found, throw an
    +      // AnalysisException.
    +      // On the resolution of the view, the output attributes are 
generated from the view schema,
    +      // and the view query is resolved later. After the view query has 
been resolved, we should
    +      // map the output of the logical plan to the output of the view, 
here we simply replace the
    +      // output attributes of the view with the attributes that have the 
same names from the child.
    +      // TODO: Also check the dataTypes and nullabilites of the output.
    +      //
    +      // Note: If the child of a view is empty, we will throw an 
AnalysisException later in
    +      // `checkAnalysis`.
    +      case v @ View(_, output, Some(child)) =>
    --- End diff --
    
    Expressions further up the tree may already be bound to the view 
attributes. So I think this is not correct, and probably needs to be the other 
way around: the child at some point must have a top-level projection that 
matches the output of the view. It might be better to this after the resolution 
phase of analysis (because the attributes might change during analysis) in a 
separate rule. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to