Skip to content
Snippets Groups Projects
Commit b0645195 authored by Reynold Xin's avatar Reynold Xin
Browse files

[SPARK-9086][SQL] Remove BinaryNode from TreeNode.

These traits are not super useful, and yet cause problems with toString in expressions due to the orders they are mixed in.

Author: Reynold Xin <rxin@databricks.com>

Closes #7433 from rxin/remove-binary-node and squashes the following commits:

1881f78 [Reynold Xin] [SPARK-9086][SQL] Remove BinaryNode from TreeNode.
parent affbe329
No related branches found
No related tags found
No related merge requests found
......@@ -187,8 +187,10 @@ 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
}
......@@ -196,9 +198,13 @@ abstract class LeafExpression extends Expression with trees.LeafNode[Expression]
* 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
......@@ -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
......
......@@ -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)
}
......@@ -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.
......
......@@ -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)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment