wangyum opened a new pull request #30222: URL: https://github.com/apache/spark/pull/30222
### What changes were proposed in this pull request? This pr simplify `CaseWhen` with `EqualTo`, for exmaple: ```sql create table t(a int, b int, c int) using parquet; SELECT * FROM (SELECT CASE WHEN a = 100 THEN 1 WHEN b > 1000 THEN 2 WHEN c IS NOT NULL THEN 3 END AS x FROM t) tmp WHERE x = 2 ``` Before this PR: ```scala == Physical Plan == *(1) Project [CASE WHEN (a#1 = 100) THEN 1 WHEN (b#2 > 1000) THEN 2 WHEN isnotnull(c#3) THEN 3 END AS x#5] +- *(1) Filter (CASE WHEN (a#1 = 100) THEN 1 WHEN (b#2 > 1000) THEN 2 WHEN isnotnull(c#3) THEN 3 END = 2) +- *(1) ColumnarToRow +- FileScan parquet default.t[a#1,b#2,c#3] Batched: true, DataFilters: [(CASE WHEN (a#1 = 100) THEN 1 WHEN (b#2 > 1000) THEN 2 WHEN isnotnull(c#3) THEN 3 END = 2)], Format: Parquet, PartitionFilters: [], PushedFilters: [], ReadSchema: struct<a:int,b:int,c:int> ``` After this PR: ```scala == Physical Plan == *(1) Project [CASE WHEN (a#1 = 100) THEN 1 WHEN (b#2 > 1000) THEN 2 WHEN isnotnull(c#3) THEN 3 END AS x#0] +- *(1) Filter (b#2 > 1000) +- *(1) ColumnarToRow +- FileScan parquet default.t[a#1,b#2,c#3] Batched: true, DataFilters: [(b#2 > 1000)], Format: Parquet, PartitionFilters: [], PushedFilters: [GreaterThan(b,1000)], ReadSchema: struct<a:int,b:int,c:int> ``` ### 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org