Github user hvanhovell commented on a diff in the pull request: https://github.com/apache/spark/pull/22429#discussion_r217913739 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala --- @@ -469,7 +470,13 @@ 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 bos = new ByteArrayOutputStream() + treeString(bos, verbose, addSuffix) + bos.toString + } + + def treeString(os: OutputStream, verbose: Boolean, addSuffix: Boolean): Unit = { --- End diff -- Can you please use a `java.io.Writer` or something else you can directly write a string to? You are now using `getBytes()` everywhere and that is far from cheap because it needs to encode the chars and allocate a byte array for each string.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org