Repository navigation
Introduce Peer-Group Start Border Sliding Index - #123737
Conversation
…_model_peer_group_starts_index
|
Workflow [PR], commit [5d250f3] Summary: ✅
AI ReviewSummaryThis PR introduces a precomputed Findings❌ Blockers
Final VerdictNeeds changes before merge: the new partition-local row bookkeeping is not applied consistently yet, and LLVM Coverage ReportMeasured on commit 5d250f3.
Changed lines: Changed C/C++ lines covered: 230/231 (99.57%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units23 translation units recompiled, 50 s compile time in total, 23 of them have a recent master baseline. |
yariks5s
left a comment
There was a problem hiding this comment.
👍
below are non-blockers to me
|
@Michicosun @yariks5s — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
…Params peer check Master's window refactor (ClickHouse#122762, ClickHouse#123260, ClickHouse#123737) moved the peer comparison into WindowTransformParams::arePeers and added SlidingIndexes, which marks peer-group starts for every RANGE and GROUPS frame with raw compareAt / getEqualRangeEndAssumeSorted. The input is sorted with the ORDER BY collator, so collation-equal values that differ in bytes (for example 'a' and 'A' under 'en-u-ks-level2') are interleaved, and the raw scan either cuts a peer group short or trips the debug check "Equal values are not contiguous within the range assumed to be sorted". Since ClickHouse#123737 this aborts deterministically for an ordinary collated rank(): SELECT rank() OVER (ORDER BY x COLLATE 'en-u-ks-level2') FROM (SELECT if(number % 2, 'a', 'A') AS x FROM numbers(1000)) The previous version of this fix lived in WindowTransform methods that the refactor removed, so it is re-done on the new structure. WindowTransformParams gets the collation flag and two helpers, haveEqualOrderByValues and getOrderByEqualRangeEnd, and every ORDER BY peer comparison goes through them: arePeers (cume_dist and the GROUPS cross-block check), the SlidingIndexes block boundary and in-block scan, the RANGE frame-end check and scan, and the GROUPS peer-group scan. PARTITION BY keys stay raw, as PARTITION BY cannot carry COLLATE. The helpers are inline in the header with the collated comparison in out-of-line cold functions, so an uncollated window keeps the inlined raw comparison of master: the earlier out-of-line version of these calls cost 15-19% on window_function_with_order in the arm performance check. The test gains the deterministic 1000-row case above (also for GROUPS), a cume_dist case and a one-row-per-block rank() case, so each of the six comparison sites has an assertion that fails when only that site compares raw. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Master's window refactor (ClickHouse#123737) replaced the runtime arePeers transition in computeReadyRows with a per-block SlidingIndex::peer_group_starts, which still marks every row as a peer group start under ROWS, so rank/dense_rank still degenerate into row_number there. Port the fix onto that model instead of the runtime prev-row comparison: - SlidingIndexes computes order_by_peer_group_starts with the same equal-range scan RANGE/GROUPS use (crossing blocks via last_order_key), only when WindowTransformParams::separate_order_by_peer_groups is set, i.e. a ROWS frame with rank or dense_rank. - WindowTransform tracks order_by_peer_group_start from that index; orderByPeerGroupStart() returns it, or peer_group_start otherwise, and rank/dense_rank read it. - No block needs to be kept alive for the check any more, and haveEqualOrderByValues is gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
This patch adds a new sliding index that will precalculate where, within the partition, peer groups start. This way we can remove the constraint on block retention that we had before - keep blocks in memory while the peer group start is still needed because it was used to compare key columns via the
arePeerspredicate.Workflow [PR]
Sync PR [sync-upstream/pr/123737]
Version info
26.10.1.1628-master(included in26.10and later)