peter-toth commented on code in PR #40268:
URL: https://github.com/apache/spark/pull/40268#discussion_r1151559781
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala:
##########
@@ -113,15 +114,13 @@ object ConstantPropagation extends Rule[LogicalPlan] {
def apply(plan: LogicalPlan): LogicalPlan = plan.transformUpWithPruning(
_.containsAllPatterns(LITERAL, FILTER), ruleId) {
case f: Filter =>
- val (newCondition, _) = traverse(f.condition, replaceChildren = true,
nullIsFalse = true)
- if (newCondition.isDefined) {
- f.copy(condition = newCondition.get)
- } else {
- f
- }
+ f.mapExpressions(traverse(_, nullIsFalse = true, None))
Review Comment:
I think this is very similar to a previous state of this PR but your version
uses an immutable `AttributeMap[(Literal, BinaryComparison)]` instead of a
mutable `Map[Expression, (Literal, BinaryComparison)]` in my PR. The addition
of maps `val equalityPredicates = equalityPredicatesLeft ++
equalityPredicatesRight` inside `And` is slower when we use immutable maps
that's why I proposed to use a mutable one.
But since that version, I changed my PR to eliminate map addition at all and
I use the mutable map as an accumulator from this commit:
https://github.com/apache/spark/pull/40268/commits/b9f3fbb990a25b54e44352329aac0625857ad15b
--
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]