[
https://issues.apache.org/jira/browse/SPARK-62393?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated SPARK-62393:
-----------------------------------
Labels: pull-request-available (was: )
> Filters that compare CASE WHEN or IF with a literal are not pushed down to
> data sources
> ---------------------------------------------------------------------------------------
>
> Key: SPARK-62393
> URL: https://issues.apache.org/jira/browse/SPARK-62393
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 5.0.0
> Reporter: Eric Yang
> Priority: Major
> Labels: pull-request-available
>
> A filter that compares a two-way CASE WHEN or IF expression with a literal is
> not pushed down to the data source when the condition can be NULL. That is
> the case for any nullable column, including every column of a Parquet or ORC
> table. The scan then reads all the data instead of skipping row groups. This
> also happens when a view defines a column as CASE WHEN ... THEN 'x' ELSE 'y'
> END and a query filters the view by that column's value.
>
> {code:java}
> CREATE TABLE t USING parquet AS SELECT id FROM range(2000000);
> SELECT count(*) FROM t WHERE CASE WHEN id > 1999990 THEN 'a' ELSE 'b' END =
> 'a';
> -- PushedFilters: [], reads 2,000,000 rows
> SELECT count(*) FROM t WHERE CASE WHEN id <= 1999990 THEN 'a' ELSE 'b' END =
> 'b';
> -- PushedFilters: [], reads 2,000,000 rows
> SELECT count(*) FROM t WHERE IF(id > 1999990, 1, 0) = 1;
> -- PushedFilters: [], reads 2,000,000 rows
> SELECT count(*) FROM t WHERE id > 1999990;
> -- PushedFilters: [IsNotNull(id), GreaterThan(id,1999990)], reads 20,000 rows
> {code}
> All four queries return 9.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]