Skip to content

Return provider extensions directly from the statistics walk - #25826

Merged
kosiew merged 3 commits into
apache:mainfrom
kosiew:cacherobust-01-25141
Oct 1, 2026
Merged

kosiew merged 3 commits into
apache:mainfrom
kosiew:cacherobust-01-25141

Conversation

@kosiew

@kosiew kosiew commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Part of #25141.

Rationale for this change

compute_extended currently reads a root node’s provider extensions back from the cache after computing its statistics. A planned change will stop caching borrowed roots, so that read would lose their extensions. Returning the extensions from the statistics walk preserves the result without depending on a root cache entry.

What changes are included in this PR?

  • Return statistics and provider extensions together from the private statistics walk. compute_extended uses that result; compute keeps returning only the statistics.
  • Continue caching provider extensions for parent nodes. On a cache hit, read them only when the caller requests them.
  • Replace ExtendedStatistics::extensions() with into_parts() to move its statistics and extensions into the walk’s result.

The public signatures of compute and compute_extended are unchanged.

Are these changes tested?

The patch adds cached_node_keeps_extensions and walk_returns_provider_extensions_directly. They cover extensions returned after a child is cached, extensions returned from a fresh provider result, and cache reads that occur only when requested.

Are there any user-facing changes?

No user-facing change is intended. This refactor preserves provider extension behavior ahead of the planned cache change.

LLM-generated code disclosure

This PR includes LLM-generated code and comments. All LLM-generated content has been manually reviewed.

- Update `StatisticsContext` to pass extensions from providers into core statistics
- Modify bottom-up walk to return `(statistics, extensions)` from provider results
- Ensure cache retains provider-attached extensions even in partition-blind cases
- Split `into_parts` to return base and extensions without cloning, improving efficiency.
- Update `StatisticsContext` to handle extension caching more precisely, avoiding redundant clones.
- Modify provider extension propagation to avoid cache-based cloning when possible, improving performance.
@github-actions github-actions Bot added the physical-plan Changes to the physical-plan crate label Sep 28, 2026
@codecov-commenter

codecov-commenter commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.23529% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.57%. Comparing base (4a5d580) to head (349d95a).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/physical-plan/src/statistics.rs 87.50% 1 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25826      +/-   ##
==========================================
- Coverage   82.58%   82.57%   -0.01%     
==========================================
  Files        1142     1142              
  Lines      440930   440940      +10     
  Branches   440930   440940      +10     
==========================================
- Hits       364126   364124       -2     
- Misses      54801    54811      +10     
- Partials    22003    22005       +2     

☔ 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, thanks @kosiew for this improvement, it's good to not pay the price of cloning extensions unless needed!

@kosiew
kosiew marked this pull request as ready for review September 29, 2026 13:33
@kosiew
kosiew force-pushed the cacherobust-01-25141 branch from 39b0e20 to c27f226 Compare September 29, 2026 13:34
@kosiew

kosiew commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@asolimando
Thank you for your review.

@kosiew
kosiew enabled auto-merge September 30, 2026 01:49
@kosiew
kosiew disabled auto-merge September 30, 2026 01:50
@kosiew
kosiew requested a review from zhuqi-lucas September 30, 2026 01:50

@zhuqi-lucas zhuqi-lucas 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.

LGTM, thanks @kosiew !

@kosiew

kosiew commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

🚀
@zhuqi-lucas
Thank you for your review.

@kosiew
kosiew added this pull request to the merge queue Oct 1, 2026
Merged via the queue into apache:main with commit 9ff61f9 Oct 1, 2026
42 checks passed
@kosiew
kosiew deleted the cacherobust-01-25141 branch October 1, 2026 05:57
Omega359 pushed a commit to Omega359/arrow-datafusion that referenced this pull request Oct 11, 2026
…25826)

## Which issue does this PR close?

Part of apache#25141.

## Rationale for this change

`compute_extended` currently reads a root node’s provider extensions
back from the cache after computing its statistics. A planned change
will stop caching borrowed roots, so that read would lose their
extensions. Returning the extensions from the statistics walk preserves
the result without depending on a root cache entry.

## What changes are included in this PR?

- Return statistics and provider extensions together from the private
statistics walk. `compute_extended` uses that result; `compute` keeps
returning only the statistics.
- Continue caching provider extensions for parent nodes. On a cache hit,
read them only when the caller requests them.
- Replace `ExtendedStatistics::extensions()` with `into_parts()` to move
its statistics and extensions into the walk’s result.

The public signatures of `compute` and `compute_extended` are unchanged.

## Are these changes tested?

The patch adds `cached_node_keeps_extensions` and
`walk_returns_provider_extensions_directly`. They cover extensions
returned after a child is cached, extensions returned from a fresh
provider result, and cache reads that occur only when requested.

## Are there any user-facing changes?

No user-facing change is intended. This refactor preserves provider
extension behavior ahead of the planned cache change.

## LLM-generated code disclosure

This PR includes LLM-generated code and comments. All LLM-generated
content has been manually reviewed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-plan Changes to the physical-plan crate v56.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants