cloud-fan commented on code in PR #36850:
URL: https://github.com/apache/spark/pull/36850#discussion_r973870661
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala:
##########
@@ -205,10 +205,14 @@ object ConstantPropagation extends Rule[LogicalPlan] {
def replaceConstants0(expression: Expression) = expression transform {
case a: AttributeReference => constantsMap.getOrElse(a, a)
}
- condition transform {
- case e @ EqualTo(_, _) if !predicates.contains(e) => replaceConstants0(e)
- case e @ EqualNullSafe(_, _) if !predicates.contains(e) =>
replaceConstants0(e)
- }
+ splitConjunctivePredicates(condition).map {
+ // Don't replace constants in IsNotNull because
InferFiltersFromConstraints may infer
+ // another IsNotNull
+ case isNotNull: IsNotNull => isNotNull
+ case e: EqualTo if predicates.contains(e) => e
Review Comment:
I get your point. I think we should rewrite the code to make the intention
more clear: we can't replace attr with constant if the attr is in the source
equal to predicates. We can set a tree node tag in the source equal to
predicates in `traverse`, and skip these source equal to predicates when
optimizing by checking the tree node tag.
--
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]