maropu commented on a change in pull request #27231: [SPARK-28478][SQL] Remove
redundant null checks
URL: https://github.com/apache/spark/pull/27231#discussion_r368776586
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -442,6 +459,13 @@ object SimplifyConditionals extends Rule[LogicalPlan]
with PredicateHelper {
case If(cond, trueValue, falseValue)
if cond.deterministic && trueValue.semanticEquals(falseValue) =>
trueValue
+ case i @ If(cond, trueValue, falseValue) => cond match {
+ // If the null-check is redundant, remove it
+ case IsNull(child) if isRedundantNullCheck(trueValue, falseValue,
child) => falseValue
+ case IsNotNull(child) if isRedundantNullCheck(falseValue, trueValue,
child) => trueValue
+ case _ => i
+ }
Review comment:
How about this format?;
```
// If the null-check is redundant, remove it
case If(IsNull(child), trueValue, falseValue)
if isRedundantNullCheck(trueValue, falseValue, child) => falseValue
case If(IsNotNull(child), trueValue, falseValue)
if isRedundantNullCheck(falseValue, trueValue, child) => trueValue
```
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]