Skip to content

fix: Preserve projections across nested caches - #29710

Merged
ritchie46 merged 1 commit into
pola-rs:mainfrom
Punisheroot:fix/js/preserve-nested-cache-projections
Oct 4, 2026
Merged

ritchie46 merged 1 commit into
pola-rs:mainfrom
Punisheroot:fix/js/preserve-nested-cache-projections

Conversation

@Punisheroot

Copy link
Copy Markdown
Contributor

Fixes #29707.

Projection pushdown recorded a cache's input during traversal. When a nested cache later added a projection to that input, the recorded value went stale, and synchronizing the cache nodes from it dropped the projection. That surfaced as unexpected columns or wrong column order in the result.

Record the optimized cache node itself and resolve its final input after the traversal. The synchronization now runs before the optimized plan is moved back into the root, so the recorded node references stay valid.

Adds regression coverage for manual, mixed, and automatic caching across column selection and ordering, on both the in-memory and streaming engines.

AI Disclosure:

  1. I used AI to diagnose the root cause and draft the fix and its tests.
  2. I confirm that I have reviewed all changes myself, and I believe they are relevant and correct.

Projection pushdown recorded a cache's input during traversal. When a
nested cache later added a projection to that input, the recorded value went
stale, and synchronizing the cache nodes from it dropped the projection. That
surfaced as unexpected columns or wrong column order in the result.

Record the optimized cache node itself and resolve its final input after the
traversal. The synchronization now runs before the optimized plan is moved
back into the root, so the recorded node references stay valid.

Fixes pola-rs#29707.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions github-actions Bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars first-contribution First contribution by user labels Oct 2, 2026
@Punisheroot

Copy link
Copy Markdown
Contributor Author

screenshot of the tests:
image

@ritchie46
ritchie46 merged commit d300f4e into pola-rs:main Oct 4, 2026
30 checks passed
@ritchie46

Copy link
Copy Markdown
Member

Thanks

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

Labels

first-contribution First contribution by user fix Bug fix python Related to Python Polars rust Related to Rust Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested caches drop projection, giving wrong results (regression in 1.43.0)

2 participants