Skip to content

[SPARK-25872][SQL][TEST] Add an optimizer tracker for TPC-DS queries #22879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product {
generateTreeString(0, Nil, new StringBuilder, verbose = verbose, addSuffix = addSuffix).toString
}

def treeNodeName(): String = {
generateTreeString(0, Nil, new StringBuilder, verbose = false, onlyNodeName = true).toString
}

/**
* Returns a string representation of the nodes in this tree, where each operator is numbered.
* The numbers can be used with [[TreeNode.apply]] to easily access specific subtrees.
Expand Down Expand Up @@ -535,7 +539,8 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product {
builder: StringBuilder,
verbose: Boolean,
prefix: String = "",
addSuffix: Boolean = false): StringBuilder = {
addSuffix: Boolean = false,
onlyNodeName: Boolean = false): StringBuilder = {

if (depth > 0) {
lastChildren.init.foreach { isLast =>
Expand All @@ -544,8 +549,10 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product {
builder.append(if (lastChildren.last) "+- " else ":- ")
}

val str = if (verbose) {
val str = if (verbose && !onlyNodeName) {
if (addSuffix) verboseStringWithSuffix else verboseString
} else if (!verbose && onlyNodeName) {
nodeName
} else {
simpleString
}
Expand All @@ -556,17 +563,17 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product {
if (innerChildren.nonEmpty) {
innerChildren.init.foreach(_.generateTreeString(
depth + 2, lastChildren :+ children.isEmpty :+ false, builder, verbose,
addSuffix = addSuffix))
addSuffix = addSuffix, onlyNodeName = onlyNodeName))
innerChildren.last.generateTreeString(
depth + 2, lastChildren :+ children.isEmpty :+ true, builder, verbose,
addSuffix = addSuffix)
addSuffix = addSuffix, onlyNodeName = onlyNodeName)
}

if (children.nonEmpty) {
children.init.foreach(_.generateTreeString(
depth + 1, lastChildren :+ false, builder, verbose, prefix, addSuffix))
depth + 1, lastChildren :+ false, builder, verbose, prefix, addSuffix, onlyNodeName))
children.last.generateTreeString(
depth + 1, lastChildren :+ true, builder, verbose, prefix, addSuffix)
depth + 1, lastChildren :+ true, builder, verbose, prefix, addSuffix, onlyNodeName)
}

builder
Expand Down
Loading