viirya commented on a change in pull request #21850:
URL: https://github.com/apache/spark/pull/21850#discussion_r480360191



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -505,6 +505,9 @@ object SimplifyConditionals extends Rule[LogicalPlan] with 
PredicateHelper {
         } else {
           e.copy(branches = branches.take(i).map(branch => (branch._1, 
elseValue)))
         }
+
+      case CaseWhen(Seq((cond, trueValue)), elseValue) =>

Review comment:
       Is it better we limit to `BooleanType` case? I.e.,
   
   ```scala
   case cw @ CaseWhen(Seq((cond, trueValue)), elseValue) if cw.dataType == 
BooleanType =>
   ```
   
   The reason is because mostly the further optimization comes from #29567, and 
it is for boolean type case only.
   
   Or just rewrite it similarly like #29567?
   
   ```scala
   case CaseWhen(Seq((cond, l @ Literal(null, _))), FalseLiteral) if 
!cond.nullable => ...
   case CaseWhen(Seq((cond, l @ Literal(null, _))), TrueLiteral) if 
!cond.nullable => ...
   ```
   




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