Skip to content
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 @@ -187,18 +187,24 @@ abstract class Expression extends TreeNode[Expression] {
/**
* A leaf expression, i.e. one without any child expressions.
*/
abstract class LeafExpression extends Expression with trees.LeafNode[Expression] {
abstract class LeafExpression extends Expression {
self: Product =>

def children: Seq[Expression] = Nil
}


/**
* An expression with one input and one output. The output is by default evaluated to null
* if the input is evaluated to null.
*/
abstract class UnaryExpression extends Expression with trees.UnaryNode[Expression] {
abstract class UnaryExpression extends Expression {
self: Product =>

def child: Expression

override def children: Seq[Expression] = child :: Nil

override def foldable: Boolean = child.foldable
override def nullable: Boolean = child.nullable

Expand Down Expand Up @@ -271,9 +277,14 @@ abstract class UnaryExpression extends Expression with trees.UnaryNode[Expressio
* An expression with two inputs and one output. The output is by default evaluated to null
* if any input is evaluated to null.
*/
abstract class BinaryExpression extends Expression with trees.BinaryNode[Expression] {
abstract class BinaryExpression extends Expression {
self: Product =>

def left: Expression
def right: Expression

override def children: Seq[Expression] = Seq(left, right)

override def foldable: Boolean = left.foldable && right.foldable

override def nullable: Boolean = left.nullable || right.nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ abstract class UnaryNode extends LogicalPlan with trees.UnaryNode[LogicalPlan] {
/**
* A logical plan node with a left and right child.
*/
abstract class BinaryNode extends LogicalPlan with trees.BinaryNode[LogicalPlan] {
abstract class BinaryNode extends LogicalPlan {
self: Product =>

def left: LogicalPlan
def right: LogicalPlan

override def children: Seq[LogicalPlan] = Seq(left, right)
}
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,6 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] {
}
}

/**
* A [[TreeNode]] that has two children, [[left]] and [[right]].
*/
trait BinaryNode[BaseType <: TreeNode[BaseType]] {
def left: BaseType
def right: BaseType

def children: Seq[BaseType] = Seq(left, right)
}

/**
* A [[TreeNode]] with no children.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ private[sql] trait UnaryNode extends SparkPlan with trees.UnaryNode[SparkPlan] {
override def outputPartitioning: Partitioning = child.outputPartitioning
}

private[sql] trait BinaryNode extends SparkPlan with trees.BinaryNode[SparkPlan] {
private[sql] trait BinaryNode extends SparkPlan {
self: Product =>

def left: SparkPlan
def right: SparkPlan

override def children: Seq[SparkPlan] = Seq(left, right)
}