Github user viirya commented on a diff in the pull request: https://github.com/apache/spark/pull/18159#discussion_r120000935 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/commands.scala --- @@ -17,38 +17,97 @@ package org.apache.spark.sql.execution.command +import scala.collection.mutable + import org.apache.spark.rdd.RDD -import org.apache.spark.sql.{Row, SparkSession} +import org.apache.spark.sql.{Row, SparkSession, SQLContext} import org.apache.spark.sql.catalyst.{CatalystTypeConverters, InternalRow} import org.apache.spark.sql.catalyst.errors.TreeNodeException import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference} import org.apache.spark.sql.catalyst.plans.{logical, QueryPlan} import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan -import org.apache.spark.sql.execution.SparkPlan +import org.apache.spark.sql.execution.{SparkPlan, SQLExecution} +import org.apache.spark.sql.execution.datasources.ExecutedWriteSummary import org.apache.spark.sql.execution.debug._ +import org.apache.spark.sql.execution.metric.{SQLMetric, SQLMetrics} import org.apache.spark.sql.execution.streaming.{IncrementalExecution, OffsetSeqMetadata} import org.apache.spark.sql.streaming.OutputMode import org.apache.spark.sql.types._ /** - * A logical command that is executed for its side-effects. `RunnableCommand`s are - * wrapped in `ExecutedCommand` during execution. + * A logical command specialized for writing data out. `WriteOutFileCommand`s are + * wrapped in `WrittenFileCommandExec` during execution. */ -trait RunnableCommand extends logical.Command { - def run(sparkSession: SparkSession, children: Seq[SparkPlan]): Seq[Row] = { +trait WriteOutFileCommand extends logical.Command { + + /** + * Those metrics will be updated once the command finishes writing data out. Those metrics will + * be taken by `WrittenFileCommandExe` as its metrics when showing in UI. + */ + def metrics(sqlContext: SQLContext): Map[String, SQLMetric] = { + val sparkContext = sqlContext.sparkContext + + Map( + // General metrics. --- End diff -- @cloud-fan I removed the part of specified metrics per file/partition. Now it is about 600 lines, and about 180 lines are tests. Do you think it's okay?
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org