Github user wangyum commented on a diff in the pull request: https://github.com/apache/spark/pull/23018#discussion_r232871356 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala --- @@ -469,7 +471,21 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product { def treeString: String = treeString(verbose = true) def treeString(verbose: Boolean, addSuffix: Boolean = false): String = { - generateTreeString(0, Nil, new StringBuilder, verbose = verbose, addSuffix = addSuffix).toString + val writer = new StringBuilderWriter() + try { + treeString(writer, verbose, addSuffix, None) + writer.toString + } finally { + writer.close() + } + } + + def treeString( + writer: Writer, + verbose: Boolean, + addSuffix: Boolean, + maxFields: Option[Int]): Unit = { + generateTreeString(0, Nil, writer, verbose, "", addSuffix) --- End diff -- How about add another function only save `nodeName`? I'll use it in another PR: https://github.com/apache/spark/pull/22879
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org