Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/19475#discussion_r144445349 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ExpressionSet.scala --- @@ -74,8 +81,24 @@ class ExpressionSet protected( } override def -(elem: Expression): ExpressionSet = { - val newBaseSet = baseSet.clone().filterNot(_ == elem.canonicalized) - val newOriginals = originals.clone().filterNot(_.canonicalized == elem.canonicalized) + if (elem.deterministic) { + val newBaseSet = baseSet.clone().filterNot(_ == elem.canonicalized) + val newOriginals = originals.clone().filterNot(_.canonicalized == elem.canonicalized) + new ExpressionSet(newBaseSet, newOriginals) + } else { + new ExpressionSet(baseSet.clone(), originals.clone()) + } + } + + override def --(elems: GenTraversableOnce[Expression]): ExpressionSet = { --- End diff -- me too, it seems only a minor optimization, to avoid cloning the `baseSet` and `originals` many times when removing multiple non-deterministic expressions. I think it's a premature optimization and let's remove it for now.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org