mhatipog opened a new pull request, #19111: URL: https://github.com/apache/iceberg/pull/19111
Fixes #19110. `pushPredicates` drops a predicate from the post-scan filters when it selects whole partitions. Iceberg expressions are two-valued, so for a NULL partition value `notEq`, `notIn`, `notStartsWith` and `notNaN` are true, while SQL treats them as unknown. Spark adds `IS NOT NULL` for a top-level comparison, which hides this, but under `OR` or `NOT` the NULL partition is selected and nothing filters it out. The predicate is now evaluated completely by Iceberg only if, after `rewriteNot`, every leaf is one that is false for NULL (`=`, `IN`, `STARTS_WITH`, `IS NULL`, `IS NOT NULL`, `isNaN`) or is on a column that a top-level or sibling `IS NOT NULL` keeps non-null. Everything else stays a post-scan filter. Plans for top-level comparisons, `NOT IN` and `IS NULL` are unchanged, so aggregate pushdown is not affected for them. This is the scan side of #18605; #18617 changes the DELETE conversion and leaves scans as they are. Backports to the other Spark versions can follow. Testing: `testFilterPushdownWithNegatedPredicatesOnNullPartition` in `TestFilterPushDown`, which fails without the change, and the existing `TestFilterPushDown` and `TestAggregatePushDown` suites. I also ran the queries from the issue against a runtime jar built from this branch on Spark 4.2.1. AI tools helped draft the change and tests; I reviewed and tested them. -- 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]
