minyyy commented on code in PR #36121:
URL: https://github.com/apache/spark/pull/36121#discussion_r846368625
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ExpressionSet.scala:
##########
@@ -74,49 +83,37 @@ class ExpressionSet protected(
protected def remove(e: Expression): Unit = {
if (e.deterministic) {
- baseSet --= baseSet.filter(_ == e.canonicalized)
- originals --= originals.filter(_.canonicalized == e.canonicalized)
+ baseSet.retain(_ != e.canonicalized)
+ originals = originals.filter(!_.semanticEquals(e))
Review Comment:
There are two changes happening in this line.
1. Changes to `originals = originals.filter(...)`. This is O(n) as the
previous implementation is O(mn).
2. Uses `semanticEquals` instead of the previous `_.canonicalized ==
e.canonicalized` as the condition. `semanticEquals` can short circuit and avoid
unnecessary access of `canonicalized` for non-deterministic expressions.
--
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]