TreeNode — Node in Catalyst Tree

TreeNode is a node in Catalyst tree with zero or more children (and can build expression or structured query plan trees).

TreeNode offers not only functions that you may have used from Scala Collection API, e.g. map, flatMap, collect, collectFirst, foreach, but also mapChildren, transform, transformDown, transformUp, foreachUp, numberedTreeString, p, asCode, prettyJson, etc. that are particularly useful for tree manipulation or debugging.

Note
Scala-specific, TreeNode is an abstract class that is the base class of Expression and Catalyst’s QueryPlan abstract classes.
Tip

TreeNode abstract type is a quite advanced Scala type definition (at least comparing to the other Scala types in Spark) so understanding its behaviour even outside Spark might be worthwhile by itself.

abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product {
  self: BaseType =>

  // ...
}

TreeNode Contract

package org.apache.spark.sql.catalyst.trees

abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product {
  self: BaseType =>

  // only required methods that have no implementation
  def children: Seq[BaseType]
  def verboseString: String
}
Table 1. (Subset of) TreeNode Contract (in alphabetical order)
Method Description

children

verboseString

withNewChildren Method

Caution
FIXME

results matching ""

    No results matching ""