Skip to content
Closed
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 @@ -78,7 +78,7 @@ case class BroadcastExchangeExec(

override lazy val metrics = Map(
"dataSize" -> SQLMetrics.createSizeMetric(sparkContext, "data size"),
"numRows" -> SQLMetrics.createMetric(sparkContext, "number of rows"),
"numOutputRows" -> SQLMetrics.createMetric(sparkContext, "number of output rows"),
"collectTime" -> SQLMetrics.createTimingMetric(sparkContext, "time to collect"),
"buildTime" -> SQLMetrics.createTimingMetric(sparkContext, "time to build"),
"broadcastTime" -> SQLMetrics.createTimingMetric(sparkContext, "time to broadcast"))
Expand All @@ -91,8 +91,8 @@ case class BroadcastExchangeExec(

override def runtimeStatistics: Statistics = {
val dataSize = metrics("dataSize").value
val numRows = metrics("numRows").value
Statistics(dataSize, Some(numRows))
val rowCount = metrics("numOutputRows").value
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

match Statistics.rowCount

Statistics(dataSize, Some(rowCount))
}

@transient
Expand All @@ -116,11 +116,11 @@ case class BroadcastExchangeExec(
val beforeCollect = System.nanoTime()
// Use executeCollect/executeCollectIterator to avoid conversion to Scala types
val (numRows, input) = child.executeCollectIterator()
longMetric("numOutputRows") += numRows
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always set the metrics even if failure happens.

if (numRows >= MAX_BROADCAST_TABLE_ROWS) {
throw new SparkException(
s"Cannot broadcast the table over $MAX_BROADCAST_TABLE_ROWS rows: $numRows rows")
}
longMetric("numRows") += numRows

val beforeBuild = System.nanoTime()
longMetric("collectTime") += NANOSECONDS.toMillis(beforeBuild - beforeCollect)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ class SQLMetricsSuite extends SharedSparkSession with SQLMetricsTestUtils
}

assert(exchanges.size === 1)
testMetricsInSparkPlanOperator(exchanges.head, Map("numRows" -> 2))
testMetricsInSparkPlanOperator(exchanges.head, Map("numOutputRows" -> 2))
}
}
}
Expand Down