Repository navigation
Conversation
|
Workflow [PR], commit [e9af7ad] Summary: ✅
AI ReviewSummaryThis PR fixes wrong primary-key pruning for Final VerdictStatus: ✅ Approve |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 26/27 (96.30%) · Uncovered code |
|
Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment. TL;DRFix primary key pruning for reversed key columns in parts without a final mark ClickGap verified: reproduced it with the script below on ReproductionCREATE TABLE t (x UInt64) ENGINE = MergeTree ORDER BY x DESC
SETTINGS index_granularity = 1, index_granularity_bytes = 0;
INSERT INTO t SELECT number FROM numbers(24);
-- expected 12, returns 1 before the fix:
SELECT count() FROM t WHERE x > 11;Bisect
Affects
Suggested next stepReview PR #106440 for the introducing change in Component: cc introducing PR author: @nikitamikhaylov ClickGap · Finding: Triage metadata
|
…ning-without-final-mark Fix primary key pruning for reversed key columns in parts without a final mark
This bug fix is needed for #96225 which will amplify any bug present in
KeyCondition.When a table has a reversed (
DESC) key column and its parts have no final mark (non-adaptive granularity,index_granularity_bytes = 0), the primary key index builds the last granule's range with the unknown side substituted as+Inf. For a reversed column the range end extends toward the smaller values, so the substituted bound must be-Infon the value-ascending left side instead. The malformed range(+Inf, mark]made the boundary search silently prune matching granules, returning wrong results:Equality and
INpredicates are affected the same way, on both the lightweight and the full primary key analysis paths. In debug builds the malformed range can also reach theInvalid binary search result in MergeTreeSetIndexlogical error.The PR also includes, currently dormant, wrong monotonic chain positivity validation.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix wrong query results caused by the primary key index incorrectly pruning granules for tables with a reversed (
DESC) key column when parts have no final mark (non-adaptive granularity,index_granularity_bytes = 0).Version info
26.7.1.1096(included in26.7and later)