Skip to content

fix: use session statistics registry in dfbench reports - #25570

Merged
gabotechs merged 4 commits into
apache:mainfrom
gabotechs:codex/dfbench-session-statistics
Oct 6, 2026
Merged

gabotechs merged 4 commits into
apache:mainfrom
gabotechs:codex/dfbench-session-statistics

Conversation

@gabotechs

@gabotechs gabotechs commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Part of #8227.

Rationale for this change

dfbench statistics unconditionally enables built-in statistics providers, so its estimates can differ from those used by the session. In TPC-H SF1 Q14, it reports 14.73 billion rows instead of 73,650 for a join that produces 75,983 rows.

Unrelated to this PR, but it's pretty weird how the built-in providers are not actually built-in unless explicitly enabled, and it's also weird how they can override the actually built-in code in each operator producing different results. It seems like there's different pieces of code with overlapping intentions and different implementation.

What changes are included in this PR?

Capture estimates using the session's registry, matching EXPLAIN ANALYZE. An unconfigured session falls back to operator statistics.

What is the testing strategy for this PR?

  • All five existing CLI statistics tests, formatting, and all-feature Clippy pass.

Are there any user-facing changes?

CLI estimates now respect the session's statistics configuration.

@gabotechs
gabotechs marked this pull request as ready for review September 21, 2026 15:32
@codecov-commenter

codecov-commenter commented Sep 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.12195% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.70%. Comparing base (d55153a) to head (377b2c1).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
benchmarks/src/statistics.rs 95.12% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25570      +/-   ##
==========================================
- Coverage   82.70%   82.70%   -0.01%     
==========================================
  Files        1147     1147              
  Lines      447631   447668      +37     
  Branches   447631   447668      +37     
==========================================
+ Hits       370222   370250      +28     
- Misses      54921    54927       +6     
- Partials    22488    22491       +3     

☔ 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.

@asolimando asolimando left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@gabotechs

Copy link
Copy Markdown
Contributor Author

cc @kosiew, as you gave a great review on the original PR. It's a trival change that should take no more than 2 mins to review.

@asolimando

Copy link
Copy Markdown
Member

@kosiew also landed #25929 which allow to share the cache "globally" without reset points, I think it can be useful here

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

@gabotechs,

Thanks for working on this. The implementation addresses the registry mismatch, but the behavior change itself is not covered by a regression test yet.

Comment thread benchmarks/src/statistics.rs

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

@gabotechs,

Thanks for adding the regression test. It now verifies the user-visible behavior by using a distinguishing session statistics provider and asserting that dfbench reports that estimate.

@gabotechs

Copy link
Copy Markdown
Contributor Author

Thanks @kosiew and @asolimando!

gabotechs added a commit to gabotechs/datafusion that referenced this pull request Oct 6, 2026
## Which issue does this PR close?

- Closes apache#25571.

## Rationale for this change

`StatisticsRegistry::default_with_builtin_providers()` registers
providers that are not the default estimation and that duplicate or
replace what the operators already do in `statistics_from_inputs`. They
can make estimates worse (TPC-H Q14: 14.73 billion rows instead of
73,650, see apache#25570), and fixes in the operators do not reach their
users. Estimation improvements belong in the operators;
`StatisticsRegistry` stays as the extension point for user-defined
providers.

## What changes are included in this PR?

- `default_with_builtin_providers()` and all seven bundled providers are
deprecated. Their code is unchanged.
- `statistics_registry.slt` and the `join_reorder` example use
user-defined providers instead of bundled ones.
- `dfbench statistics` reports the operators' own estimates instead of
the bundled providers' estimates.

Follow-ups: moving the Filter distinct count survival model into
`FilterExec` (apache#26052); multi-key join estimation is tracked in apache#21583.

## What is the testing strategy for this PR?

`statistics_registry.slt` passes unchanged; the `join_reorder` example
still flips the build side.

## Are there any user-facing changes?

Deprecations only, see the 56.0.0 upgrade guide.

----

Disclaimer: I used AI to assist in the code generation, I have manually
reviewed the output and it matches my intention and understanding.

---------

Co-authored-by: Gabriel <45515538+gabotechs@users.noreply.github.com>
@gabotechs
gabotechs enabled auto-merge October 6, 2026 08:42
@gabotechs
gabotechs added this pull request to the merge queue Oct 6, 2026
Merged via the queue into apache:main with commit 264ee3d Oct 6, 2026
42 checks passed
@gabotechs
gabotechs deleted the codex/dfbench-session-statistics branch October 6, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants