wangyum commented on a change in pull request #30852:
URL: https://github.com/apache/spark/pull/30852#discussion_r546672625
##########
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:
It may be `null` in Project. It seems it should be in
`ReplaceNullWithFalseInPredicate`, this is an example in Project:
```
spark-sql> create table t1 using parquet as select id from range(5);
spark-sql> select (CASE WHEN id = 1 THEN 'a' WHEN id = 3 THEN 'b' end) = 'c'
from t1;
NULL
false
false
NULL
NULL
```
```
spark-sql> select * from t1 where (CASE WHEN id = 1 THEN 'a' WHEN id = 3
THEN 'b' end) = 'c';
spark-sql>
```
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]