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

    https://github.com/apache/spark/pull/22713#discussion_r225486497
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/view.scala 
---
    @@ -112,8 +112,8 @@ object EliminateView extends Rule[LogicalPlan] {
       def apply(plan: LogicalPlan): LogicalPlan = plan transform {
         // The child should have the same output attributes with the View 
operator, so we simply
         // remove the View operator.
    -    case View(_, output, child) =>
    -      assert(output == child.output,
    +    case v @ View(_, output, child) =>
    +      assert(v.sameOutput(child),
    --- End diff --
    
    I added the check and I found a case which may be considered as a bug (not 
sure honestly, it is a weird situation which I think might occur, but it a bad 
condition, which we may want to handle differently).
    
    Currently the rule doesn't work well when the output of the view and the 
output of its child differs because of some nullable. You can find an example 
in the UT I added, where the view has all the output attributes as nullable, 
while the child has one as not-nullable. In this case, we are currently failing 
with an exception in the optimizer rule `EliminateView`. After the change, the 
plan is correctly created.


---

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

Reply via email to