[SPARK-2965][SQL] Fix HashOuterJoin output nullabilities.

Output attributes of opposite side of `OuterJoin` should be nullable.

Author: Takuya UESHIN <ueshin@happy-camper.st>

Closes #1887 from ueshin/issues/SPARK-2965 and squashes the following commits:

bcb2d37 [Takuya UESHIN] Fix HashOuterJoin output nullabilities.
This commit is contained in:
Takuya UESHIN 2014-08-11 20:15:01 -07:00 committed by Michael Armbrust
parent 647aeba3a9
commit c9c89c31b6

View file

@ -168,7 +168,18 @@ case class HashOuterJoin(
override def requiredChildDistribution =
ClusteredDistribution(leftKeys) :: ClusteredDistribution(rightKeys) :: Nil
def output = left.output ++ right.output
override def output = {
joinType match {
case LeftOuter =>
left.output ++ right.output.map(_.withNullability(true))
case RightOuter =>
left.output.map(_.withNullability(true)) ++ right.output
case FullOuter =>
left.output.map(_.withNullability(true)) ++ right.output.map(_.withNullability(true))
case x =>
throw new Exception(s"HashOuterJoin should not take $x as the JoinType")
}
}
// TODO we need to rewrite all of the iterators with our own implementation instead of the Scala
// iterator for performance purpose.