Skip to content

Commit 18e28b2

Browse files
committed
added a test case
1 parent 1ccbfa8 commit 18e28b2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/trees/TreeNodeSuite.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,17 @@ class TreeNodeSuite extends FunSuite {
117117
assert(transformed.origin.startPosition.isDefined)
118118
}
119119

120+
test("foreach up") {
121+
val actual = new ArrayBuffer[String]()
122+
val expected = Seq("1", "2", "3", "4", "-", "*", "+")
123+
val expression = Add(Literal(1), Multiply(Literal(2), Subtract(Literal(3), Literal(4))))
124+
expression foreachUp {
125+
case b: BinaryExpression => actual.append(b.symbol);
126+
case l: Literal => actual.append(l.toString);
127+
}
128+
129+
assert(expected === actual)
130+
}
131+
120132

121133
}

0 commit comments

Comments
 (0)