wangyum opened a new pull request #34580:
URL: https://github.com/apache/spark/pull/34580


   ### What changes were proposed in this pull request?
   
   This pr fix push foldable into CaseWhen branches if elseValue is empty. For 
example:
   ```scala
   spark.sql("CREATE TABLE t1(bool boolean, number int) using parquet")
   spark.sql("INSERT INTO t1 VALUES(false, 1)")
   
   spark.sql(
     """
       |SELECT *
       |FROM   (SELECT *,
       |               CASE
       |                 WHEN bool THEN 'I am not null'
       |               END AS conditions
       |        FROM   t1) t
       |WHERE  conditions IS NULL
       |""".stripMargin).show
   }
   ```
   
   How do we optimize the filter conditions before this pr:
   ```
   Filter isnull(CASE WHEN bool#7 THEN I am not null END) -> Filter CASE WHEN 
bool#7 THEN isnull(I am not null) END -> Filter (bool#7 AND isnull(I am not 
null)) -> Filter (bool#7 AND false)
   ```
   
   How do we optimize the filter conditions after this pr:
   ```
   Filter isnull(CASE WHEN bool#7 THEN I am not null END) -> Filter CASE WHEN 
bool#7 THEN isnull(I am not null) ELSE isnull(null) END -> Filter CASE WHEN 
bool#7 THEN false ELSE isnull(null) END -> Filter CASE WHEN bool#7 THEN false 
ELSE true END -> Filter NOT (bool#7 <=> true)
   ```
   
   ### Why are the changes needed?
   
   Fix correctness issue.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Unit test.
   


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to