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

    https://github.com/apache/spark/pull/13290#discussion_r64686215
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -1448,6 +1450,37 @@ class Analyzer(
       }
     
       /**
    +   * Fixes nullability of Attributes in a resolved LogicalPlan by using 
the nullability of
    +   * corresponding Attributes of its children output Attributes. This step 
is needed because
    +   * users can use a resolved AttributeReference in the Dataset API and 
outer joins
    +   * can change the nullability of an AttribtueReference. Without the fix, 
a nullable column's
    +   * nullable field can be actually set as non-nullable, which cause 
illegal optimization
    +   * (e.g., NULL propagation) and wrong answers.
    +   * See SPARK-13484 and SPARK-13801 for the concrete queries of this case.
    +   */
    +  object FixNullability extends Rule[LogicalPlan] {
    +
    +    def apply(plan: LogicalPlan): LogicalPlan = plan transformUp {
    +      case q: LogicalPlan if q.resolved =>
    +        val childrenOutput = q.children.flatMap(c => 
c.output).groupBy(_.exprId).flatMap {
    --- End diff --
    
    Yea. This version tries to fix the nullability for the entire query plan 
tree because I think it is possible to hit this problem in other cases when 
using Dataset API.


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