olaky commented on code in PR #48867:
URL: https://github.com/apache/spark/pull/48867#discussion_r1847264497
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V1FallbackWriters.scala:
##########
@@ -58,14 +59,27 @@ case class OverwriteByExpressionExecV1(
sealed trait V1FallbackWriters extends LeafV2CommandExec with SupportsV1Write {
override def output: Seq[Attribute] = Nil
+ override val metrics: Map[String, SQLMetric] =
+ write.supportedCustomMetrics().map { customMetric =>
+ customMetric.name() -> SQLMetrics.createV2CustomMetric(sparkContext,
customMetric)
+ }.toMap
+
def table: SupportsWrite
def refreshCache: () => Unit
def write: V1Write
override def run(): Seq[InternalRow] = {
- val writtenRows = writeWithV1(write.toInsertableRelation)
+ writeWithV1(write.toInsertableRelation)
refreshCache()
- writtenRows
+
+ write.reportDriverMetrics().foreach { customTaskMetric =>
+
metrics.get(customTaskMetric.name()).foreach(_.set(customTaskMetric.value()))
+ }
+
+ val executionId =
sparkContext.getLocalProperty(SQLExecution.EXECUTION_ID_KEY)
+ SQLMetrics.postDriverMetricUpdates(sparkContext, executionId,
metrics.values.toSeq)
+
+ metrics.get("numOutputRows").map(metric => InternalRow(metric.value,
metric.value)).toSeq
Review Comment:
Agreed
--
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]