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 2020/02/05 07:01:52 UTC

[GitHub] [spark] maropu commented on a change in pull request #27231: [SPARK-28478][SQL] Remove redundant null checks

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_r375086787
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
 ##########
 @@ -434,6 +434,27 @@ object SimplifyConditionals extends Rule[LogicalPlan] with PredicateHelper {
     case _ => false
   }
 
+  /**
+   * Condition for redundant null check based on intolerant expressions.
+   * @param ifNullExpr expression that takes place if checkedExpr is null
+   * @param ifNotNullExpr expression that takes place if checkedExpr is not null
+   * @param checkedExpr expression that is checked for null value
+   */
+  private def isRedundantNullCheck(
+      ifNullExpr: Expression,
+      ifNotNullExpr: Expression,
+      checkedExpr: Expression): Boolean = {
+    val isNullIntolerant = ifNotNullExpr.find { x =>
+      !x.isInstanceOf[NullIntolerant] && x.find(e => e.semanticEquals(checkedExpr)).nonEmpty
 
 Review comment:
   Probably, you meant `FiterExec.isNullIntolerant(ifNotNullExpr) || additional checks for the case having null-tolerant exprs inside ifNotNullExpr`? (`FiterExec.isNullIntolerant` is private though...)

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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