Skip to content

refactor(pruning): deprecate PruningPredicate::try_new - #24129

Merged
zhuqi-lucas merged 4 commits into
apache:mainfrom
goutamadwant:gh-24128-pruning-predicate-builder
Aug 7, 2026
Merged

zhuqi-lucas merged 4 commits into
apache:mainfrom
goutamadwant:gh-24128-pruning-predicate-builder

Conversation

@goutamadwant

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

PruningPredicateBuilder is the extensible entry point for constructing pruning predicates, but the construction logic still lived behind PruningPredicate::try_new. Keeping the logic in the builder provides one place to add future construction options and guides callers toward the extensible API.

What changes are included in this PR?

  • Move pruning predicate construction into PruningPredicateBuilder::try_build.
  • Deprecate PruningPredicate::try_new and retain it as a compatibility wrapper using the builder defaults.
  • Migrate DataFusion call sites and examples to PruningPredicateBuilder.
  • Add a regression test confirming the deprecated constructor and builder produce equivalent predicates.

Are these changes tested?

Yes. The following checks pass:

  • cargo fmt --all -- --check
  • cargo test -p datafusion-pruning
  • cargo test -p datafusion-datasource-parquet
  • cargo check -p datafusion-examples --examples
  • cargo clippy -p datafusion-pruning -p datafusion-datasource-parquet -p datafusion-examples --all-targets --all-features -- -D warnings
  • cargo test --profile=ci --test sqllogictests
  • cargo test -p datafusion
  • cargo test -p datafusion-cli
  • RUSTDOCFLAGS="-D warnings" cargo doc -p datafusion-pruning --no-deps

The workspace-wide clippy command is currently blocked on main by an existing clippy::uninlined_format_args diagnostic in datafusion/proto-common/src/generated/pbjson.rs. The same failure reproduces from a clean checkout of the base commit; all modified packages pass strict clippy checks.

Are there any user-facing changes?

Yes. PruningPredicate::try_new is deprecated as of 55.0.0. It remains available as a compatibility wrapper with unchanged behavior. New callers should construct predicates with PruningPredicateBuilder.

@github-actions

github-actions Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Thank you for opening this pull request!

Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch).

Details
     Cloning apache/main
    Building datafusion-datasource-parquet v54.1.0 (current)
       Built [  52.199s] (current)
     Parsing datafusion-datasource-parquet v54.1.0 (current)
      Parsed [   0.034s] (current)
    Building datafusion-datasource-parquet v54.1.0 (baseline)
       Built [  44.948s] (baseline)
     Parsing datafusion-datasource-parquet v54.1.0 (baseline)
      Parsed [   0.034s] (baseline)
    Checking datafusion-datasource-parquet v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.217s] 223 checks: 223 pass, 30 skip
     Summary no semver update required
    Finished [  99.369s] datafusion-datasource-parquet
    Building datafusion-pruning v54.1.0 (current)
       Built [  39.332s] (current)
     Parsing datafusion-pruning v54.1.0 (current)
      Parsed [   0.013s] (current)
    Building datafusion-pruning v54.1.0 (baseline)
       Built [  39.239s] (baseline)
     Parsing datafusion-pruning v54.1.0 (baseline)
      Parsed [   0.014s] (baseline)
    Checking datafusion-pruning v54.1.0 -> v54.1.0 (no change; assume patch)
     Checked [   0.098s] 223 checks: 222 pass, 1 fail, 0 warn, 30 skip

--- failure type_method_marked_deprecated: type method #[deprecated] added ---

Description:
A type method is now #[deprecated]. Downstream crates will get a compiler warning when using this method.
        ref: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-deprecated-attribute
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.49.0/src/lints/type_method_marked_deprecated.ron

Failed in:
  method datafusion_pruning::PruningPredicate::try_new in /home/runner/work/datafusion/datafusion/datafusion/pruning/src/pruning_predicate.rs:598

     Summary semver requires new minor version: 0 major and 1 minor checks failed
    Finished [  79.838s] datafusion-pruning

@github-actions github-actions Bot added the auto detected api change Auto detected API change label Aug 6, 2026
@codecov-commenter

codecov-commenter commented Aug 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.32710% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.05%. Comparing base (24483db) to head (db1016e).

Files with missing lines Patch % Lines
datafusion/pruning/src/pruning_predicate.rs 92.42% 0 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24129      +/-   ##
==========================================
- Coverage   81.05%   81.05%   -0.01%     
==========================================
  Files        1106     1106              
  Lines      380556   380596      +40     
  Branches   380556   380596      +40     
==========================================
+ Hits       308477   308507      +30     
- Misses      53861    53867       +6     
- Partials    18218    18222       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zhuqi-lucas

Copy link
Copy Markdown
Contributor

Should we add upgrade guide also?

@alamb alamb 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.

Thank you @goutamadwant -- this looks great

I had one small suggestion

cc @zhuqi-lucas

FYI @kosiew I think the PruningPredicateBuilder may be a natural place to wire in the cache from #21566

/// Specifically, this example illustrates how to:
/// 1. Use [`ParquetFileReaderFactory`] to avoid re-reading parquet metadata on each query
/// 2. Use [`PruningPredicate`] for predicate analysis
/// 2. Use [`datafusion::physical_optimizer::pruning::PruningPredicate`] for predicate analysis

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.

can we avoid adding this full path and make it a normal link? (leave it PruningPredicate and then add a definition for pruning predicate below?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I updated this @alamb. I restored the PruningPredicate link and added its reference definition alongside the existing documentation links. Let me know if this is good.

// `PruningPredicate::prune` would likely be easier to do.
let pruning_predicate =
PruningPredicate::try_new(Arc::clone(predicate), self.schema())?;
let pruning_predicate = PruningPredicateBuilder::new()

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.

❤️

pub fn try_build(self, predicate: Arc<dyn PhysicalExpr>) -> Result<PruningPredicate> {
pub fn try_build(
self,
mut predicate: Arc<dyn PhysicalExpr>,

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.

it is strange this got reformatted -- but clearly nothing you did

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right. I left this unchanged for now. :)

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 7, 2026
@goutamadwant

Copy link
Copy Markdown
Contributor Author

Should we add upgrade guide also?

@zhuqi-lucas added an entry to the DataFusion 55 upgrade guide documenting the deprecation and the equivalent PruningPredicateBuilder migration. Let me know if any suggestions. thanks!

@zhuqi-lucas

Copy link
Copy Markdown
Contributor

LGTM, thank you @goutamadwant and @alamb ! Merged now.

@zhuqi-lucas
zhuqi-lucas added this pull request to the merge queue Aug 7, 2026
Merged via the queue into apache:main with commit f05869b Aug 7, 2026
38 checks passed
kosiew pushed a commit to kosiew/datafusion that referenced this pull request Aug 12, 2026
## Which issue does this PR close?

- Closes apache#24128.

## Rationale for this change

`PruningPredicateBuilder` is the extensible entry point for constructing
pruning predicates, but the construction logic still lived behind
`PruningPredicate::try_new`. Keeping the logic in the builder provides
one place to add future construction options and guides callers toward
the extensible API.

## What changes are included in this PR?

- Move pruning predicate construction into
`PruningPredicateBuilder::try_build`.
- Deprecate `PruningPredicate::try_new` and retain it as a compatibility
wrapper using the builder defaults.
- Migrate DataFusion call sites and examples to
`PruningPredicateBuilder`.
- Add a regression test confirming the deprecated constructor and
builder produce equivalent predicates.

## Are these changes tested?

Yes. The following checks pass:

- `cargo fmt --all -- --check`
- `cargo test -p datafusion-pruning`
- `cargo test -p datafusion-datasource-parquet`
- `cargo check -p datafusion-examples --examples`
- `cargo clippy -p datafusion-pruning -p datafusion-datasource-parquet
-p datafusion-examples --all-targets --all-features -- -D warnings`
- `cargo test --profile=ci --test sqllogictests`
- `cargo test -p datafusion`
- `cargo test -p datafusion-cli`
- `RUSTDOCFLAGS="-D warnings" cargo doc -p datafusion-pruning --no-deps`

The workspace-wide clippy command is currently blocked on `main` by an
existing `clippy::uninlined_format_args` diagnostic in
`datafusion/proto-common/src/generated/pbjson.rs`. The same failure
reproduces from a clean checkout of the base commit; all modified
packages pass strict clippy checks.

## Are there any user-facing changes?

Yes. `PruningPredicate::try_new` is deprecated as of 55.0.0. It remains
available as a compatibility wrapper with unchanged behavior. New
callers should construct predicates with `PruningPredicateBuilder`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto detected api change Auto detected API change datasource Changes to the datasource crate documentation Improvements or additions to documentation v55.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate PruningPredicate::try_new in favor of PruningPredicateBuilder

5 participants