Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
parthchandra committed Apr 22, 2024
1 parent a478826 commit b909fa8
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class CometSparkSessionExtensions
s"Schema $requiredSchema is not supported")
val info2 = createMessage(
!isSchemaSupported(partitionSchema),
s"Schema $partitionSchema is not supported")
s"Partition schema $partitionSchema is not supported")
withInfo(scanExec, Seq(info1, info2).flatten.mkString(","))
scanExec
}
Expand Down Expand Up @@ -996,6 +996,24 @@ object CometSparkSessionExtensions extends Logging {
node
}

/**
* Attaches explain information to a TreeNode, rolling up the corresponding information tags
* from any child nodes
*
* @param node
* The node to attach the explain information to. Typically a SparkPlan
* @param exprs
* Child nodes. Information attached in these nodes will be be included in the information
* attached to @node
* @tparam T
* The type of the TreeNode. Typically SparkPlan, AggregateExpression, or Expression
* @return
* The node with information (if any) attached
*/
def withInfo[T <: TreeNode[_]](node: T, exprs: T*): T = {
withInfo(node, "", exprs: _*)
}

// Helper to reduce boilerplate
def createMessage(condition: Boolean, message: => String): Option[String] = {
if (condition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class ExtendedExplainInfo extends ExtendedExplainGenerator {
info.filter(!_.contentEquals("\n"))
}

// get all plan nodes, breadth first, leaf nodes first
// get all plan nodes, breadth first traversal, then returned the reversed list so
// leaf nodes are first
private def sortup(node: TreeNode[_]): mutable.Queue[TreeNode[_]] = {
val ordered = new mutable.Queue[TreeNode[_]]()
val traversed = mutable.Queue[TreeNode[_]](getActualPlan(node))
Expand Down
Loading

0 comments on commit b909fa8

Please sign in to comment.