Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/1266#discussion_r14543110
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicOperators.scala
---
@@ -46,10 +46,22 @@ case class Generate(
child: LogicalPlan)
extends UnaryNode {
- protected def generatorOutput: Seq[Attribute] =
- alias
+ protected def generatorOutput: Seq[Attribute] = {
+ val output = alias
.map(a => generator.output.map(_.withQualifiers(a :: Nil)))
.getOrElse(generator.output)
+ if (join && outer) {
+ output.map {
+ case attr if !attr.resolved => attr
+ case attr if !attr.nullable =>
+ AttributeReference(
+ attr.name, attr.dataType, nullable = true)(attr.exprId,
attr.qualifiers)
+ case attr => attr
--- End diff --
This is a pretty common pattern. We already have
[`withNullability`](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/namedExpressions.scala#L136),
which you could use in these cases if we move it up as an abstract method in
`Attribute` and add a no-op version in `UnresolvedAttribute`.
---
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.
---