Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ case class Filter(condition: Expression, child: LogicalPlan) extends UnaryNode {
}

case class Union(left: LogicalPlan, right: LogicalPlan) extends BinaryNode {
// TODO: These aren't really the same attributes as nullability etc might change.
override def output: Seq[Attribute] = left.output
override def output: Seq[Attribute] =
left.output.zip(right.output).map { case (leftAttr, rightAttr) =>
leftAttr.withNullability(leftAttr.nullable || rightAttr.nullable)
}

override lazy val resolved: Boolean =
childrenResolved &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ case class Sample(
*/
@DeveloperApi
case class Union(children: Seq[SparkPlan]) extends SparkPlan {
// TODO: attributes output by union should be distinct for nullability purposes
override def output: Seq[Attribute] = children.head.output
override def output: Seq[Attribute] = {
children.tail.foldLeft(children.head.output) { case (currentOutput, child) =>
currentOutput.zip(child.output).map { case (a1, a2) =>
a1.withNullability(a1.nullable || a2.nullable)
}
}
}
protected override def doExecute(): RDD[Row] = sparkContext.union(children.map(_.execute()))
}

Expand Down