zecookiez commented on code in PR #49816:
URL: https://github.com/apache/spark/pull/49816#discussion_r1962111791
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateStore.scala:
##########
@@ -281,10 +285,20 @@ object StateStoreMetrics {
customMetric -> sumOfMetrics
}.toMap
+ val distinctInstanceMetrics =
allMetrics.flatMap(_.instanceMetrics.keys).distinct
+ val instanceMetrics = allMetrics.flatMap(_.instanceMetrics)
+ val combinedInstanceMetrics = distinctInstanceMetrics.map { instanceMetric
=>
+ val sameMetrics = instanceMetrics.filter(_._1 == instanceMetric)
+ // Use the instance metric's custom ordering to select the combined
metric value
+ val selectedMetrics = sameMetrics.map(_._2).min(instanceMetric.ordering)
+ instanceMetric -> selectedMetrics
Review Comment:
This is one thing I need help confirming. Given the use case of this method
to combine left + right stores I'm fairly sure (please correct me if I'm wrong)
we will not encounter a case where the metric is the complete same with
identical state store name + partition. If that is the case, would it be better
to handle this in another way?
--
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]