davintjong-db commented on code in PR #44649:
URL: https://github.com/apache/spark/pull/44649#discussion_r1446919073
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/metric/SQLMetrics.scala:
##########
@@ -62,8 +62,8 @@ class SQLMetric(
override def merge(other: AccumulatorV2[Long, Long]): Unit = other match {
case o: SQLMetric =>
- if (o.isValid) {
- if (!isValid) _value = defaultValidValue
+ if (!o.isZero) {
+ if (isZero) _value = 0
Review Comment:
This was the issue before - in the case of an optional metric,
`defaultValidValue` will be negative. So if we were to add a value to this
metric, it would be subtracted by this sentinel value, so we want to set it to
`0`.
We want `defaultValidValue` defines what is exposed via `value()`, not where
to start counting - that's where I got confused the first time around.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]