ZiyaZa commented on code in PR #55576:
URL: https://github.com/apache/spark/pull/55576#discussion_r3159596286


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/WriteToDataSourceV2Exec.scala:
##########
@@ -350,9 +350,14 @@ case class ReplaceDataExec(
         // One of the metrics couldn't be found, also mark numDeletedRows as 
not found.
         -1L
       }
+
+      // SQLMetric.set call is a no-op if value is -1. Override numDeletedRows 
value in summary.
       metrics("numDeletedRows").set(numDeletedRows)
+      super.getWriteSummary(query)
+        .map(_.asInstanceOf[DeleteSummaryImpl].copy(numDeletedRows = 
numDeletedRows))

Review Comment:
   Changed it to pattern-matching instead. I want to call 
`super.getWriteSummary` here because in future we might have more fields inside 
`DeleteSummaryImpl`, and repeating the same code here is not ideal.
   
   Note that even if we set the initial value of the metric as -1, accessing 
`.value` would still give us 0 as SQLMetric hides negative values.
   
   If you have a better proposal here, I can change it.



-- 
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]

Reply via email to