You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/09/07 12:08:30 UTC

[GitHub] [spark] cloud-fan commented on a diff in pull request #36850: [SPARK-39069][SQL] Enhance ConstantPropagation to replace constants in inequality predicates

cloud-fan commented on code in PR #36850:
URL: https://github.com/apache/spark/pull/36850#discussion_r964761349


##########
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
+      case e: EqualNullSafe if predicates.contains(e) => e

Review Comment:
   previously we can optimize `EqualTo(...) Or EqualTo(...)` because we use `condition.transform`. Seems it's not the case now after your change?



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org