@@ -200,34 +200,18 @@ trait ProgressReporter extends Logging {
200200 }
201201 }
202202
203- /** Extract statistics about event time from the executed query plan . */
204- private def extractEventTimeStats ( ): Map [ String , String ] = {
203+ /** Extracts statistics from the most recent query execution . */
204+ private def extractExecutionStats ( hasNewData : Boolean ): ExecutionStats = {
205205 val hasEventTime = logicalPlan.collect { case e : EventTimeWatermark => e }.nonEmpty
206206 val watermarkTimestamp =
207207 if (hasEventTime) Map (" watermark" -> formatTimestamp(offsetSeqMetadata.batchWatermarkMs))
208208 else Map .empty[String , String ]
209209
210- if (lastExecution == null || ! hasEventTime) return watermarkTimestamp
211-
212- lastExecution.executedPlan.collect {
213- case e : EventTimeWatermarkExec if e.eventTimeStats.value.count > 0 =>
214- val stats = e.eventTimeStats.value
215- Map (
216- " max" -> stats.max,
217- " min" -> stats.min,
218- " avg" -> stats.avg).mapValues(formatTimestamp)
219- }.headOption.getOrElse(Map .empty)
220- }
221-
222- /** Extracts statistics from the most recent query execution. */
223- private def extractExecutionStats (hasNewData : Boolean ): ExecutionStats = {
224-
225210 // SPARK-19378: Still report metrics even though no data was processed while reporting progress.
226211 val stateOperators = extractStateOperatorMetrics(hasNewData)
227- val eventTimeStats = extractEventTimeStats()
228212
229213 if (! hasNewData) {
230- return ExecutionStats (Map .empty, stateOperators, eventTimeStats )
214+ return ExecutionStats (Map .empty, stateOperators, watermarkTimestamp )
231215 }
232216
233217 // We want to associate execution plan leaves to sources that generate them, so that we match
@@ -276,6 +260,15 @@ trait ProgressReporter extends Logging {
276260 Map .empty
277261 }
278262
263+ val eventTimeStats = lastExecution.executedPlan.collect {
264+ case e : EventTimeWatermarkExec if e.eventTimeStats.value.count > 0 =>
265+ val stats = e.eventTimeStats.value
266+ Map (
267+ " max" -> stats.max,
268+ " min" -> stats.min,
269+ " avg" -> stats.avg).mapValues(formatTimestamp)
270+ }.headOption.getOrElse(Map .empty) ++ watermarkTimestamp
271+
279272 ExecutionStats (numInputRows, stateOperators, eventTimeStats)
280273 }
281274
0 commit comments