Skip to content

Improve predicate pushdown coverage in cudf-polars - #23143

Open
Matt711 wants to merge 8 commits into
NVIDIA:mainfrom
Matt711:parquet-pushdown-coverage
Open

Improve predicate pushdown coverage in cudf-polars#23143
Matt711 wants to merge 8 commits into
NVIDIA:mainfrom
Matt711:parquet-pushdown-coverage

Conversation

@Matt711

@Matt711 Matt711 commented Jul 7, 2026

Copy link
Copy Markdown
Member

Description

A predicate that is pushed down to a Scan in the logical plan does not imply it's used in the libcudf parquet reader for row group pruning based on statistics and the post read filter in libcudf. The predicate must first be translatable to libcudf AST. If it is not, then we use the predicate to filter (post read) at the end of Scan execution. This PR makes two improvements

  1. For conjunctive predicates, we can push down conjuncts that we do support converting to AST (think "partial predicate pushdown")
  2. Allow boolean functions is_null and is_not_null to pass through AST conversion because they are supported. I'll do another audit here to see if there are anymore we can allow through.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@Matt711
Matt711 requested a review from a team as a code owner July 7, 2026 15:35
@Matt711 Matt711 added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jul 7, 2026
@Matt711
Matt711 requested a review from TomAugspurger July 7, 2026 15:35
@github-actions github-actions Bot added Python Affects Python cuDF API. cudf-polars Issues specific to cudf-polars labels Jul 7, 2026
@GPUtester GPUtester moved this to In Progress in cuDF Python Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bcad50b2-f996-476e-9380-b1e27b527841

📥 Commits

Reviewing files that changed from the base of the PR and between 7ddbae9 and 75ac2ba.

📒 Files selected for processing (5)
  • python/cudf_polars/cudf_polars/dsl/ir.py
  • python/cudf_polars/cudf_polars/dsl/to_ast.py
  • python/cudf_polars/cudf_polars/streaming/actor_graph/io.py
  • python/cudf_polars/tests/dsl/test_to_ast.py
  • python/cudf_polars/tests/test_parquet_filters.py

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Improved Parquet filter handling so more predicates can be pushed down during reads, including partial support when only some conditions can be applied early.
    • Added support for null-check filters in Parquet pushdown and better handling of combined filter expressions.
  • Bug Fixes

    • Reduced unnecessary post-read filtering by more accurately detecting when a Parquet filter is fully applied.
    • Expanded test coverage for string-based and compound filter cases to prevent regressions.

Walkthrough

The PR changes to_parquet_filter to return a tuple of the converted expression and an "exact" boolean instead of just an optional expression. Consumers in ir.py and actor_graph/io.py now use this exactness flag to decide fallback/masking behavior. Tests were added/extended accordingly.

Changes

Parquet filter exactness

Layer / File(s) Summary
to_parquet_filter conversion and exactness logic
python/cudf_polars/cudf_polars/dsl/to_ast.py
Relaxes parquet BooleanFunction handling for IsNull/IsNotNull on columns, adds _extract_conjuncts and _to_parquet_filter helpers, and reworks to_parquet_filter to return (expr, exact) by attempting whole-predicate conversion then per-conjunct fallback.
Scan and streaming read node consumption
python/cudf_polars/cudf_polars/dsl/ir.py, python/cudf_polars/cudf_polars/streaming/actor_graph/io.py
Scan.do_evaluate and make_rapidsmpf_read_parquet_node capture filters_exact and use it instead of filter presence to decide whether post-read masking or pushdown fallback is needed.
Tests for exactness and new filter expressions
python/cudf_polars/tests/dsl/test_to_ast.py, python/cudf_polars/tests/test_parquet_filters.py
Adds parametrized tests for to_parquet_filter exactness on null-check and conjunction/disjunction predicates, and extends parquet filter test expressions with string-predicate combinations.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • rapidsai/cudf#21460: Both PRs modify Parquet predicate handling in make_rapidsmpf_read_parquet_node, changing pushdown/fallback decision logic.

Suggested labels: 3 - Ready for Review

Suggested reviewers: madsbk

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: improved predicate pushdown coverage in cudf-polars.
Description check ✅ Passed The description directly matches the changeset and explains the predicate pushdown improvements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@TomAugspurger TomAugspurger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice. Might have an issue with struct columns though:

FAILED py-polars/tests/unit/io/test_delta.py::test_scan_delta_predicate_pushdown_struct_is_not_null - ValueError: CUDF failure at: /__w/cudf/cudf/cpp/src/io/parquet/predicate_pushdown.cpp:162: Column chunk with schema index 1 not found in source 0

https://github.com/rapidsai/cudf/actions/runs/28878719201/job/85673148030?pr=23143#step:13:2937

Comment thread python/cudf_polars/cudf_polars/streaming/actor_graph/io.py Outdated
Comment thread python/cudf_polars/cudf_polars/dsl/to_ast.py Outdated
@vyasr

vyasr commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@Matt711 do you want to pick this back up?

Comment thread python/cudf_polars/cudf_polars/dsl/to_ast.py Outdated
@Matt711
Matt711 requested a review from wence- July 23, 2026 20:16

@wence- wence- left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny nit

Comment on lines +270 to +276
def _extract_conjuncts(node: expr.Expr) -> list[expr.Expr]:
if (
isinstance(node, expr.BinOp)
and node.op == plc.binaryop.BinaryOperator.NULL_LOGICAL_AND
):
return [c for child in node.children for c in _extract_conjuncts(child)]
return [node]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this destroys the dag structure of the expression since it re-traverses all children even if they are already seen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cudf-polars Issues specific to cudf-polars improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

6 participants