dilipbiswal commented on a change in pull request #24759: [SPARK-27395][SQL] 
Improve EXPLAIN command
URL: https://github.com/apache/spark/pull/24759#discussion_r316510915
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/Exchange.scala
 ##########
 @@ -77,6 +77,15 @@ case class ReusedExchangeExec(override val output: 
Seq[Attribute], child: Exchan
   override def outputOrdering: Seq[SortOrder] = {
     child.outputOrdering.map(updateAttr(_).asInstanceOf[SortOrder])
   }
+
+  override def verboseStringWithOperatorId(): String = {
+    val cdgen = ExplainUtils.getCodegenId(this)
+    val reuse_op_str = ExplainUtils.getOpId(child)
+    s"""
+       |(${ExplainUtils.getOpId(this)}) $nodeName ${cdgen} [Reuses operator 
id: $reuse_op_str]
 
 Review comment:
   @cloud-fan I think we are okay here. Here is a simple plan involving 
`ReusedSubqueryExec`
   ```
   explain formatted select (select avg(a) from s1) + (select avg(a) from s1) 
from s1 limit 1;
   ```
   ```
   == Physical Plan ==
   CollectLimit (3)
   +- * Project (2)
      +- Scan hive default.s1 (1)
   
   
   (1) Scan hive default.s1 
   Output: []
        
   (2) Project [codegen id : 1]
   Output    : [(Subquery scalar-subquery#151 + ReusedSubquery Subquery 
scalar-subquery#151) AS (scalarsubquery() + scalarsubquery())#168]
   Input     : []
        
   (3) CollectLimit 
   Input: [(scalarsubquery() + scalarsubquery())#168]
        
   ===== Subqueries =====
   
   Subquery:1 Hosting operator id = 2 Hosting Expression = Subquery 
scalar-subquery#151
   * HashAggregate (7)
   +- Exchange (6)
      +- * HashAggregate (5)
         +- Scan hive default.s1 (4)
   
   
   (4) Scan hive default.s1 
   Output: [a#160]
        
   (5) HashAggregate [codegen id : 1]
   Input: [a#160]
        
   (6) Exchange 
   Input: [sum#171, count#172L]
        
   (7) HashAggregate [codegen id : 2]
   Input: [sum#171, count#172L]
        
   Subquery:2 Hosting operator id = 2 Hosting Expression = ReusedSubquery 
Subquery scalar-subquery#151
   ```
   Please let me know what you think.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to