Github user gengliangwang commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20020#discussion_r158333591
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/commands.scala 
---
    @@ -87,6 +87,44 @@ case class ExecutedCommandExec(cmd: RunnableCommand) 
extends LeafExecNode {
       }
     }
     
    +/**
    + * A physical operator that executes the run method of a 
`DataWritingCommand` and
    + * saves the result to prevent multiple executions.
    + *
    + * @param cmd the `DataWritingCommand` this operator will run.
    + * @param child the physical plan child ran by the `DataWritingCommand`.
    + */
    +case class DataWritingCommandExec(cmd: DataWritingCommand, child: 
SparkPlan)
    +  extends SparkPlan {
    +
    +  override lazy val metrics: Map[String, SQLMetric] = cmd.metrics
    +
    +  protected[sql] lazy val sideEffectResult: Seq[InternalRow] = {
    +    val converter = 
CatalystTypeConverters.createToCatalystConverter(schema)
    +    val rows = cmd.run(sqlContext.sparkSession, child)
    +
    +    rows.map(converter(_).asInstanceOf[InternalRow])
    +  }
    +
    +  override def children: Seq[SparkPlan] = child :: Nil
    +
    +  override def innerChildren: Seq[QueryPlan[_]] = cmd :: Nil
    --- End diff --
    
    I was following `ExecutedCommandExec`. And I can see some slight difference 
with`explain` command. I can remove it.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to