Skip to content

Window function perf: Cache nth_value valid indices#23019

Draft
Dandandan wants to merge 1 commit into
apache:mainfrom
Dandandan:codex/window-valid-index-cache
Draft

Window function perf: Cache nth_value valid indices#23019
Dandandan wants to merge 1 commit into
apache:mainfrom
Dandandan:codex/window-valid-index-cache

Conversation

@Dandandan

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

  • N/A.

Rationale for this change

Cache valid row positions for nth_value window evaluation with IGNORE NULLS to avoid rescanning validity bitmaps for each frame.

What changes are included in this PR?

  • Add a lazy per-evaluator valid-index cache for nth_value IGNORE NULLS evaluation.
  • Reuse cached non-null row positions across frame evaluations.
  • Add regression tests for cached ranges including backward and empty-valid-row ranges.

Are these changes tested?

  • cargo fmt --all
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test -p datafusion-functions-window nth_value --lib
  • cargo bench -p datafusion-functions-window --bench nth_value -- nth_value_ignore_nulls/last_value_expanding/50% --sample-size 10 --warm-up-time 1 --measurement-time 2

Benchmark median: 260.09 us. Original baseline: 14.239 ms.

Are there any user-facing changes?

No API or behavior changes; performance improvement only.

@github-actions github-actions Bot added the functions Changes to functions implementation label Jun 18, 2026
@Dandandan Dandandan changed the title [codex] Cache nth_value valid indices Window function: Cache nth_value valid indices Jun 18, 2026
@Dandandan Dandandan changed the title Window function: Cache nth_value valid indices Window function perf: Cache nth_value valid indices Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant