wangyum commented on code in PR #36850: URL: https://github.com/apache/spark/pull/36850#discussion_r966887563
########## 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: This is a improvement, For example: ``` (a > b + 1 && b = 1 || c = 1) && (b = 1) ===> (a > 2 || c = 1) && (b = 1) ``` It cannot be optimized before. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org