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

    https://github.com/apache/spark/pull/12099#discussion_r58275150
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/commands.scala 
---
    @@ -237,15 +237,18 @@ case class ExplainCommand(
         logicalPlan: LogicalPlan,
         override val output: Seq[Attribute] =
           Seq(AttributeReference("plan", StringType, nullable = true)()),
    -    extended: Boolean = false)
    +    extended: Boolean = false,
    +    codegen: Boolean = false)
       extends RunnableCommand {
     
       // Run through the optimizer to generate the physical plan.
       override def run(sqlContext: SQLContext): Seq[Row] = try {
         // TODO in Hive, the "extended" ExplainCommand prints the AST as well, 
and detailed properties.
         val queryExecution = sqlContext.executePlan(logicalPlan)
    -    val outputString = if (extended) queryExecution.toString else 
queryExecution.simpleString
    -
    +    var outputString = if (extended) queryExecution.toString else 
queryExecution.simpleString
    +    if (codegen) {
    +      outputString = codegenString(queryExecution.executedPlan)
    --- End diff --
    
    **Detected unnecessary var.**
    
    Suggested improvement:
    ```
    val outputString
      if (codegen) {
        codegenString(queryExecution.executedPlan)
      } else if (extended) {
        queryExecution.toString
      } else {
        queryExecution.simpleString
      }
    ```


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to