perf: Extend WindowTopN to dense_rank#23869
Open
SubhamSinghal wants to merge 2 commits into
Open
Conversation
|
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 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #23869 +/- ##
========================================
Coverage 80.72% 80.72%
========================================
Files 1090 1090
Lines 370384 370914 +530
Branches 370384 370914 +530
========================================
+ Hits 298975 299414 +439
- Misses 53590 53623 +33
- Partials 17819 17877 +58 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dense_rank
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
ROW_NUMBER < 5/ TopK #6899. Completes the ROW_NUMBER + RANK + DENSE_RANK trio requested by the issue (ROW_NUMBER shipped in Perf: Window topn optimisation #21479; RANK is in flight as PR A).Rationale for this change
Naive plan for
Filter(dr <= K) → BoundedWindowAggExec(DENSE_RANK) → SortExec(pk, ob) → inputsorts the full input even though only rows at the K distinct-smallest ob values per partition are needed. DENSE_RANK is stable under tail-pruning, so the rewrite preserves ranks for every retained row.What changes are included in this PR?
Are these changes tested?
Yes
h2o bench — Q24–Q29 added; top-2 on 10M-row
large, 3-iter avg vsenable_window_topn=false:Are there any user-facing changes?
No breaking changes. Rule fires on DENSE_RANK when
datafusion.optimizer.enable_window_topn = true; flag staysfalseby default