Github user maropu commented on a diff in the pull request:
https://github.com/apache/spark/pull/13290#discussion_r64532662
--- 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 {
+ case (exprId, attributes) =>
+ // If there are multiple Attributes having the same ExpirId,
we need to resolve
--- End diff --
Nit: ExpirId -> ExprId
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]