Skip to content

[SPARK-40608][SQL] Push necessary predicates from partially translatable V2 filters - #58948

Open
xiaoh1024 wants to merge 1 commit into
apache:masterfrom
xiaoh1024:fix/spark-40608-partial-v2-filters
Open

xiaoh1024 wants to merge 1 commit into
apache:masterfrom
xiaoh1024:fix/spark-40608-partial-v2-filters

Conversation

@xiaoh1024

Copy link
Copy Markdown

What changes were proposed in this pull request?

Extract necessary predicates when a V2 scan filter cannot be fully translated, for both SupportsPushDownFilters and SupportsPushDownV2Filters. Retain the original expression for post-scan filtering.

For example, id = 1 OR (id = 2 AND split(name, ',')[0] = 'fred') can push id = 1 OR id = 2 while Spark evaluates the original condition.

Why are the changes needed?

An unsupported expression in one branch currently prevents the entire OR predicate from being pushed down, even when both branches imply a translatable condition. Extracting that condition lets the data source filter rows earlier.

Does this PR introduce any user-facing change?

Yes. Eligible V2 scans push an additional filter; query results are unchanged.

How was this patch tested?

Added regression tests covering both filter APIs, residual filtering, NULL values, unsupported OR branches, NOT, non-deterministic expressions, and fully translatable filters. Added an H2 JDBC test checking the pushed predicate and query results.

Was this patch authored or co-authored using generative AI tooling?

Yes.

@xiaoh1024
xiaoh1024 marked this pull request as ready for review September 21, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant