wangyum commented on a change in pull request #30852: URL: https://github.com/apache/spark/pull/30852#discussion_r546997382
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/ReplaceNullWithFalseInPredicate.scala ########## @@ -94,6 +94,7 @@ object ReplaceNullWithFalseInPredicate extends Rule[LogicalPlan] { replaceNullWithFalse(cond) -> replaceNullWithFalse(value) } val newElseValue = cw.elseValue.map(replaceNullWithFalse) + .orElse(if (newBranches.forall(_._2 == FalseLiteral)) Some(FalseLiteral) else None) Review comment: ~~How about another approach, just add this to `SimplifyConditionals`? The logic is clear and simple:~~ ```scala case cw @ CaseWhen(_, elseValue) if cw.dataType == BooleanType && elseValue.isEmpty => cw.copy(elseValue = Some(FalseLiteral)) ``` ---------------------------------------------------------------- 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