maropu commented on a change in pull request #29389:
URL: https://github.com/apache/spark/pull/29389#discussion_r467523040



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/BroadcastExchangeExec.scala
##########
@@ -82,6 +82,8 @@ case class BroadcastExchangeExec(
     "buildTime" -> SQLMetrics.createTimingMetric(sparkContext, "time to 
build"),
     "broadcastTime" -> SQLMetrics.createTimingMetric(sparkContext, "time to 
broadcast"))
 
+  var zeroNumRows: Boolean = false

Review comment:
       nit: How about rewriting it like this?
   ```
   +  private var knownRowCount: Option[BigInt] = None
   +
      override def runtimeStatistics: Statistics = {
        val dataSize = metrics("dataSize").value
   -    Statistics(dataSize, rowCount = if (zeroNumRows) Some(0L) else None)
   +    Statistics(dataSize, rowCount = knownRowCount)
      }
    
      @transient
   @@ -128,6 +128,9 @@ case class BroadcastExchangeExec(
                val relation = mode.transform(input, Some(numRows))
    
                val dataSize = relation match {
   +              case EmptyHashedRelation =>
   +                knownRowCount = Some(0L)
   +                0L
                  case map: HashedRelation =>
                    map.estimatedSize
                  case arr: Array[InternalRow] =>
   @@ -137,7 +140,6 @@ case class BroadcastExchangeExec(
                      s"type: ${relation.getClass.getName}")
                }
    
   -            zeroNumRows = relation == EmptyHashedRelation
   
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to