sunchao commented on a change in pull request #29567:
URL: https://github.com/apache/spark/pull/29567#discussion_r479674614



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -463,6 +463,8 @@ object SimplifyConditionals extends Rule[LogicalPlan] with 
PredicateHelper {
       case If(Literal(null, _), _, falseValue) => falseValue
       case If(cond, trueValue, falseValue)
         if cond.deterministic && trueValue.semanticEquals(falseValue) => 
trueValue
+      case If(p, l @ Literal(null, _), FalseLiteral) if !p.nullable => And(p, 
l)
+      case If(p, l @ Literal(null, _), TrueLiteral) if !p.nullable => 
Or(Not(p), l)

Review comment:
       I'm yet to find a case where `If(p, null, false)` gets populated to 
datasource. I think most of the time they just get replaced by `false` so 
transforming them to `And(p, null)` doesn't seem to help much.
   
   On the other hand, `Or(Not(p), null)` does get pushed down to datasources.




----------------------------------------------------------------
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.

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

Reply via email to