Skip to content

Commit 2ccb721

Browse files
marmbrusconcretevitamin
authored andcommitted
Add support for transformation of optional children.
1 parent 1c04652 commit 2ccb721

File tree

1 file changed

+16
-0
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees

1 file changed

+16
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] {
187187
} else {
188188
arg
189189
}
190+
case Some(arg: TreeNode[_]) if children contains arg =>
191+
val newChild = arg.asInstanceOf[BaseType].transformDown(rule)
192+
if (!(newChild fastEquals arg)) {
193+
changed = true
194+
Some(newChild)
195+
} else {
196+
Some(arg)
197+
}
190198
case m: Map[_,_] => m
191199
case args: Traversable[_] => args.map {
192200
case arg: TreeNode[_] if children contains arg =>
@@ -231,6 +239,14 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] {
231239
} else {
232240
arg
233241
}
242+
case Some(arg: TreeNode[_]) if children contains arg =>
243+
val newChild = arg.asInstanceOf[BaseType].transformUp(rule)
244+
if (!(newChild fastEquals arg)) {
245+
changed = true
246+
Some(newChild)
247+
} else {
248+
Some(arg)
249+
}
234250
case m: Map[_,_] => m
235251
case args: Traversable[_] => args.map {
236252
case arg: TreeNode[_] if children contains arg =>

0 commit comments

Comments
 (0)