You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by liancheng <gi...@git.apache.org> on 2016/05/31 23:02:50 UTC

[GitHub] spark pull request: [SPARK-13484] [SQL] Prevent illegal NULL propagation whe...

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

    https://github.com/apache/spark/pull/13290#discussion_r65278045
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
    @@ -1448,6 +1450,38 @@ 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 p if !p.resolved => p // Skip unresolved nodes.
    +      case p: LogicalPlan if p.resolved =>
    +        val childrenOutput = p.children.flatMap(c => c.output).groupBy(_.exprId).flatMap {
    +          case (exprId, attributes) =>
    +            // If there are multiple Attributes having the same ExprId, we need to resolve
    --- End diff --
    
    Then should we just put an `assert`/`require` here?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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