WangGuangxin commented on a change in pull request #26899: [SPARK-28332][SQL] Reserve init value -1 only when do min max statistics in SQLMetrics URL: https://github.com/apache/spark/pull/26899#discussion_r358586175
########## File path: sql/core/src/main/scala/org/apache/spark/sql/execution/metric/SQLMetrics.scala ########## @@ -67,7 +67,9 @@ class SQLMetric(val metricType: String, initValue: Long = 0L) extends Accumulato def +=(v: Long): Unit = _value += v - override def value: Long = _value + def getRawValue(): Long = _value + + override def value: Long = Math.max(_value, 0) Review comment: What I want to do here is when we want to distinguish an uninitialized metric by -1, then we can use `SQLMetric.getRawValue`(It's the same with what current SQLMetric does without this PR). Otherwise use `SQLMetrics.value` to make sure it returns at least 0 (It's the same with initializing SQLMetric to 0). It's a bit tricky. `SQLMetric.getRawValue` was called in `SQLAppStatusListener.onTaskEnd` and `SQLMetrics.postDriverMetricUpdates`. The metric values in these two places eventually go to `LiveStageMetrics` used by `SQLAppStatusListener.aggregateMetrics` and then aggregated in `SQLMetrics.stringValue`. If a SQLMetric is initialized by -1 and it was not got updated in executors, then this metric value is -1 and can be filtered by logic in `SQLMetrics.stringValue`. ---------------------------------------------------------------- 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] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
