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_r368784740
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala ########## @@ -483,6 +507,19 @@ object SimplifyConditionals extends Rule[LogicalPlan] with PredicateHelper { } else { e.copy(branches = branches.take(i).map(branch => (branch._1, elseValue))) } + + case e @ CaseWhen(branches, elseValue) if branches.length == 1 => + // remove redundant null checks for CaseWhen with one branch + branches(0)._1 match { + case IsNotNull(child) if isRedundantNullCheck( + elseValue.getOrElse(Literal.create(null, child.dataType)), Review comment: `child.dataType` -> `e.dataType`? ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org