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


   ### What changes were proposed in this pull request?
   
   This pr replace None of elseValue inside `CaseWhen` with `FalseLiteral` if 
all branches are `FalseLiteral` . The use case is:
   ```sql
   create table t1 using parquet as select id from range(10);
   explain select id from t1 where (CASE WHEN id = 1 THEN 'a' WHEN id = 3 THEN 
'b' end) = 'c';
   ```
   
   Before this pr:
   ```
   == Physical Plan ==
   *(1) Filter CASE WHEN (id#1L = 1) THEN false WHEN (id#1L = 3) THEN false END
   +- *(1) ColumnarToRow
      +- FileScan parquet default.t1[id#1L] Batched: true, DataFilters: [CASE 
WHEN (id#1L = 1) THEN false WHEN (id#1L = 3) THEN false END], Format: Parquet, 
Location: 
InMemoryFileIndex[file:/Users/yumwang/opensource/spark/spark-warehouse/org.apache.spark.sql.DataF...,
 PartitionFilters: [], PushedFilters: [], ReadSchema: struct<id:bigint>
   
   ```
   
   After this pr:
   ```
   == Physical Plan ==
   LocalTableScan <empty>, [id#1L]
   ```
   
   ### Why are the changes needed?
   
   Improve query performance.
   
   
   ### 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.

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