MaxGekk commented on a change in pull request #23406: [SPARK-26504][SQL] 
Rope-wise dumping of Spark plans
URL: https://github.com/apache/spark/pull/23406#discussion_r244544539
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/QueryExecution.scala
 ##########
 @@ -197,55 +193,65 @@ class QueryExecution(
   }
 
   def simpleString: String = withRedaction {
-    s"""== Physical Plan ==
-       |${stringOrError(executedPlan.treeString(verbose = false))}
-      """.stripMargin.trim
+    val rope = new StringRope()
+
+    rope.append("== Physical Plan ==\n")
+    appendOrError(rope.append)(
+      executedPlan.treeString(_, false, false, SQLConf.get.maxToStringFields))
+    rope.append("\n")
+
+    rope.toString
   }
 
-  private def writeOrError(writer: Writer)(f: Writer => Unit): Unit = {
-    try f(writer)
+  private def appendOrError(append: String => Unit)(f: (String => Unit) => 
Unit): Unit = {
 
 Review comment:
   Will be ok if I move `appendOrError` to the companion object of `QueryPlan`? 
Like:
   ```scala
   object QueryPlan extends PredicateHelper {
     /**
      * Converts the query plan to string and appends it via provided function.
      */
     def append[T <: QueryPlan[T]](
         plan: => QueryPlan[T],
         append: String => Unit,
         verbose: Boolean,
         addSuffix: Boolean,
         maxFields: Int = SQLConf.get.maxToStringFields): Unit = { () }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to