bhollis-dbx commented on code in PR #58800:
URL: https://github.com/apache/spark/pull/58800#discussion_r4075560403
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/trees/TreeNodeSuite.scala:
##########
@@ -180,6 +181,76 @@ class TreeNodeSuite extends SparkFunSuite with SQLHelper {
assert(actual === expect)
}
+ test("mapChildren returns the original node when all children are fast
equal") {
+ val expression = Coalesce(Seq(Literal(1), Literal(2)))
+ val visited = new ArrayBuffer[Int]()
+ val result = expression.mapChildren {
+ case literal @ Literal(value: Int, _) =>
+ visited += value
+ literal
+ case other => other
+ }
+
+ assert(result eq expression)
+ assert(visited == Seq(1, 2))
+ val leaf = Dummy(None)
+ assert(leaf.mapChildren(identity) eq leaf)
+ }
+
+ test("mapChildren returns the original node when every child is equal but a
distinct copy") {
+ val expression = Coalesce(Seq(Literal(1), Literal(2)))
+ // Return a fresh, structurally-equal (not reference-equal) copy for
*every* child: this
+ // fills `equalCopies` yet must still return `this`, since no child
materially changes.
Review Comment:
Added a reference-equal prefix, full identity/order assertions, and removed
the stale equalCopies wording.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]