Skip to content
Closed
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 @@ -580,39 +580,37 @@ case class Union(
allowMissingCol: Boolean = false) extends UnionBase {
assert(!allowMissingCol || byName, "`allowMissingCol` can be true only if `byName` is true.")

override def maxRows: Option[Long] = {
var sum = BigInt(0)
children.foreach { child =>
if (child.maxRows.isDefined) {
sum += child.maxRows.get
if (!sum.isValidLong) {
return None
override lazy val maxRows: Option[Long] = {
Comment thread
cloud-fan marked this conversation as resolved.
val sum = children.foldLeft(Option(BigInt(0))) {
case (Some(acc), child) =>
child.maxRows match {
case Some(n) =>
val newSum = acc + n
if (newSum.isValidLong) Some(newSum) else None
case None => None
}
} else {
return None
}
case (None, _) => None
}
Some(sum.toLong)
sum.map(_.toLong)
}

final override val nodePatterns: Seq[TreePattern] = Seq(UNION)

/**
* Note the definition has assumption about how union is implemented physically.
*/
override def maxRowsPerPartition: Option[Long] = {
var sum = BigInt(0)
children.foreach { child =>
if (child.maxRowsPerPartition.isDefined) {
sum += child.maxRowsPerPartition.get
if (!sum.isValidLong) {
return None
override lazy val maxRowsPerPartition: Option[Long] = {
val sum = children.foldLeft(Option(BigInt(0))) {
case (Some(acc), child) =>
child.maxRowsPerPartition match {
case Some(n) =>
val newSum = acc + n
if (newSum.isValidLong) Some(newSum) else None
case None => None
}
} else {
return None
}
case (None, _) => None
}
Some(sum.toLong)
sum.map(_.toLong)
}

private def duplicatesResolvedPerBranch: Boolean =
Expand Down Expand Up @@ -666,7 +664,7 @@ case class Join(
hint: JoinHint)
extends BinaryNode with PredicateHelper {

override def maxRows: Option[Long] = {
override lazy val maxRows: Option[Long] = {
joinType match {
case Inner | Cross | FullOuter | LeftOuter | RightOuter | LeftSingle
if left.maxRows.isDefined && right.maxRows.isDefined =>
Expand Down