aokolnychyi commented on code in PR #55576:
URL: https://github.com/apache/spark/pull/55576#discussion_r3182482117
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/WriteToDataSourceV2Exec.scala:
##########
@@ -350,9 +350,15 @@ 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 {
Review Comment:
These calls to super and then adjusting output is a sign that we may need to
split the parent method into smaller blocks and override those.
What about something like below?
```
private def buildMergeSummary(): Option[WriteSummary] = {
collectFirst(query) { case m: MergeRowsExec => m }.map { n =>
...
}
}
private def buildUpdateSummary(): Option[WriteSummary] = {
...
}
protected def buildDeleteSummary(): Option[WriteSummary] = {
...
}
override protected def buildWriteSummary(): Option[WriteSummary] = {
rowLevelCommand match {
case MERGE => buildMergeSummary()
case UPDATE => buildUpdateSummary()
case DELETE => buildDeleteSummary()
}
}
```
Then you only need to override `buildDeleteSummary`.
--
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]