Github user yjshen commented on the pull request:

    https://github.com/apache/spark/pull/7986#issuecomment-128231658
  
    The reason for the bug:
    
    Give `EXPLAIN CREATE TABLE t1 SELECT * FROM exist_table` as an example.
    `ExplainCommand(CreateTableAsSelect)` is used internally to run the command:
    ```scala
    val queryExecution = sqlContext.executePlan(logicalPlan/*It is 
CreateTableAsSelect in this case*/)
    val outputString = if (extended) queryExecution.toString else 
queryExecution.simpleString
    ```
    After analysing phase, createTableAsSelect was converted to another 
RunnableCommand, which is a leaf operator by default:
    ``` scala
    private[sql] trait RunnableCommand extends LogicalPlan with logical.Command 
{
      override def children: Seq[LogicalPlan] = Seq.empty
    ```
    Therefore, no further optimisation or planning is feasible in this case.


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

Reply via email to