Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/10099#discussion_r46395934
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala
---
@@ -395,11 +395,24 @@ abstract class TreeNode[BaseType <:
TreeNode[BaseType]] extends Product {
}
/** Appends the string represent of this node and its children to the
given StringBuilder. */
- protected def generateTreeString(depth: Int, builder: StringBuilder):
StringBuilder = {
- builder.append(" " * depth)
- builder.append(simpleString)
- builder.append("\n")
- children.foreach(_.generateTreeString(depth + 1, builder))
+ protected def generateTreeString(
+ depth: Int, lastChildren: Seq[Boolean], builder: StringBuilder):
StringBuilder = {
+ val prefix = if (depth == 0) {
+ ""
+ } else {
+ (lastChildren.init.map { isLast =>
+ if (isLast) " " else ": "
+ } :+ (if (lastChildren.last) s"+- " else ":- ")).mkString
--- End diff --
this may be arguably more readable:
```
lastChildren.init.map { isLast =>
if (isLast) " " else ": "
}.mkString + (if (lastChildren.last) "+- " else ":- ")
```
---
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]