refactor: address review feedback on percentile_cont(DISTINCT) accumulator - #23946
Merged
Conversation
Follow-up to the DistinctPercentileContAccumulator fix, addressing post-merge review comments: - Use the fast foldhash RandomState for the `counts` map instead of the standard library's default SipHash, matching GenericDistinctBuffer. - Compute size() via estimate_memory_size, mirroring the other distinct accumulators. - Add a null-free fast path to update_batch and retract_batch that skips the per-element validity check when the input array has no nulls. - Add ORDER BY id to the sliding-window regression query in aggregate.slt so its output row order is deterministic. Co-authored-by: Claude Code
Add a grouped percentile_cont(DISTINCT ...) regression test. A GROUP BY with target_partitions=4 forces two-phase (Partial + FinalPartitioned) aggregation, so the distinct accumulator's state() and merge_batch() paths run — the paths the previous whole-table regression queries did not reach (flagged by patch-coverage review on apache#23913). Duplicate values within each group also verify multiplicity is preserved across the per-partition merge. Co-authored-by: Claude Code
Per review discussion: if `retract_batch` is asked to remove a value not in the count map, the accumulator's state has diverged from the window frame and continuing would silently produce wrong results. Return an `internal_err!` instead of skipping, so the inconsistency surfaces rather than yielding a wrong answer. Co-authored-by: Claude Code
neilconway
approved these changes
Jul 28, 2026
neilconway
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the quick turnaround! lgtm
Member
Author
|
Thank you @neilconway for the reviews |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #23946 +/- ##
=======================================
Coverage 80.69% 80.70%
=======================================
Files 1095 1095
Lines 372626 372542 -84
Branches 372626 372542 -84
=======================================
- Hits 300700 300651 -49
+ Misses 53978 53924 -54
- Partials 17948 17967 +19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add a sliding-window percentile_cont(DISTINCT ...) regression over data containing a NULL positioned so that both the update_batch (NULL row enters the frame) and retract_batch (NULL row leaves the frame) code paths take the null_count() > 0 branch. Verified via temporary eprintln that both branches execute; the previous distinct-percentile tests used no NULLs and left those branches uncovered. Co-authored-by: Claude Code
This was referenced Jul 28, 2026
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.
Rationale for this change
Follow-up to post-merge review feedback from @neilconway on #23913.
What changes are included in this PR?
RandomStatefor the distinct-value count map instead of the standard library's default SipHash (the sharedGenericDistinctBufferalready does this; the merged fix regressed to SipHash on this hot path).estimate_memory_sizeinsize()instead of a hand-rolled capacity calculation.update_batch/retract_batch(skip per-element validity checks when the input has no nulls), mirroringGenericDistinctBuffer.ORDER BYto the sliding-window regression test so its row order is deterministic.Are these changes tested?
Yes — existing percentile unit tests and the full
aggregate.sltpass.Are there any user-facing changes?
No.