Repository navigation
Fix set skip index not pruning granules over LowCardinality columns - #107868
Conversation
|
Workflow [PR], commit [b861998] Summary: ✅
AI ReviewSummaryThis PR fixes Final VerdictStatus: ✅ Approve |
`MergeTreeIndexConditionSet::traverseDAG` wraps each WHERE atom with `__bitWrapperFunc` to coerce it to a `BoolMask`. `__bitWrapperFunc` is defined only for integer arguments, so #105384 started wrapping an atom only when `WhichDataType(removeNullable(atom->result_type)).isInteger()` and otherwise fell back to `UNKNOWN_FIELD` (the index keeps every granule and the query goes through the regular filter path). That fix correctly handles `Float` atoms (#105355) and `LowCardinality(Nullable)` atoms (#105938), where wrapping would throw "It's a bug!" or coerce a NULL granule value to `0` and wrongly prune. But it strips only `Nullable`, not `LowCardinality`. Over a non-nullable `LowCardinality(String)` column, function predicates such as `hasToken`, `LIKE` or `match` produce `LowCardinality(UInt8)`, which is not "integer", so every atom became `UNKNOWN_FIELD` and the `set` index stopped pruning entirely -- turning an index lookup into a full scan with large read amplification. A plain `String` column yields `UInt8` and was unaffected, which is why the regression was specific to `LowCardinality`. Look through `LowCardinality` before the integer check. The wrapper is stripped only for `LowCardinality` types and, unlike the plain case, `Nullable` is not stripped afterwards, so `LowCardinality(UInt8)` is wrapped and prunes again while `LowCardinality(Nullable(...))` keeps falling back to `UNKNOWN_FIELD` and the #105938 fix is preserved. `__bitWrapperFunc` accepts `LowCardinality(UInt8)`, which is how these predicates pruned before #105384. Caused by: #105384 Closes: #107881 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
set skip index not pruning granules over LowCardinality columns
This reverts commit ce2ee0f.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 7/7 (100.00%) | Lost baseline coverage: none · Uncovered code |
Cherry pick #107868 to 26.3: Fix `set` skip index not pruning granules over `LowCardinality` columns
…ver `LowCardinality` columns
Cherry pick #107868 to 26.4: Fix `set` skip index not pruning granules over `LowCardinality` columns
…ver `LowCardinality` columns
…ver `LowCardinality` columns
Cherry pick #107868 to 25.8: Fix `set` skip index not pruning granules over `LowCardinality` columns
…ver `LowCardinality` columns
Backport #107868 to 26.3: Fix `set` skip index not pruning granules over `LowCardinality` columns
Backport #107868 to 26.4: Fix `set` skip index not pruning granules over `LowCardinality` columns
Backport #107868 to 26.5: Fix `set` skip index not pruning granules over `LowCardinality` columns
|
Could you please expedite the backport of this MR (Matchmaking Service) update? I need to upgrade from ClickHouse Cloud version 25.12 to 26.2 as soon as possible. |
Backports are complete, which version is missing for you? |
Caused by #105384
Closes #107881
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix set skip index not pruning granules over LowCardinality columns.
Version info
26.6.1.112826.5.4.8,26.4.5.64,26.3.16.2