[SPARK-49038][SQL][3.5] SQLMetric should report the raw value in the accumulator update event #47749
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
backport #47721 to 3.5
What changes were proposed in this pull request?
Some
SQLMetricsset the initial value to-1, so that we can recognize no-update metrics (e.g. there is no input data and the metric is not updated at all) and filter them out later in the UI.However, there is a bug here. Spark turns accumulator updates into
AccumulableInfo, usingAccumulatorV2#value. To avoid exposing the internal-1value to end users,SQLMetric#valueturns-1into0before returning the value. See more details in #39311 . UI can no longer see-1and filter them out.This PR fixes the bug by using the raw value of
SQLMetricto createAccumulableInfo, so that UI can still see-1and filters it.Why are the changes needed?
To avoid getting the wrong min value for certain SQL metrics when some partitions have no data.
Does this PR introduce any user-facing change?
Yes, if people write spark listeners to watch the
SparkListenerExecutorMetricsUpdateevent, they can see the correct value of SQL metrics.How was this patch tested?
manual UI tests. We do not have an end-to-end UI test framework for SQL metrics yet.
Was this patch authored or co-authored using generative AI tooling?
no