Repository navigation
Test set skip index OR with LowCardinality(Nullable) (issue #105938) - #105990
alexey-milovidov merged 2 commits into
Conversation
|
Pre-PR validation gate (session (a) Deterministic repro: yes. The smaller reproducer from @den-crane on #105938 (100 + 10 rows, no random settings) returns (b) Root cause explained: yes. (c) Fix matches root cause: N/A here, this PR is test-only locking down the existing fix in #105384. (d) Test intent preserved: yes. The test asserts equality between (e) Both directions demonstrated: yes. Locally reverted only the integer-type check hunk added by #105384 to (f) Fix is general, not a narrow patch: N/A (test-only PR). The fix in #105384 already covers all non-integer atom result types via the |
|
Workflow [PR], commit [829f86d] Summary: ✅ AI ReviewSummaryThis PR adds a focused stateless regression test for the Final VerdictStatus: ✅ Approve |
The first `SELECT count()` is the canonical bug trigger from ClickHouse#105938 / ClickHouse#105384. As written, the stateless runner randomizes `use_skip_indexes_on_data_read` and `use_skip_indexes_for_disjunctions` across runs. When either disables the partial-disjunction skip-index path in `MergeTreeDataSelectExecutor` / `ReadFromMergeTree`, the buggy `MergeTreeIndexConditionSet::traverseDAG` wrapping is never exercised and a pre-fix binary returns the same `100` as a post-fix binary, so the regression would silently slip through. Pin the four settings that gate the buggy path on that query directly via per-query `SETTINGS`, so the test always exercises the fix: use_skip_indexes = 1 use_skip_indexes_on_data_read = 0 use_skip_indexes_for_disjunctions = 1 use_query_condition_cache = 0 The other two queries are intentionally left alone: the second forces `use_skip_indexes = 0` as the no-index control, and the third uses `assumeNotNull(n)` so the atom result type is no longer `LowCardinality(Nullable(UInt8))` and the bug cannot trigger. Addresses bot review on PR ClickHouse#105990.
…issue ClickHouse#105938) Locks down the fix from ClickHouse#105384 against issue ClickHouse#105938, where a `WHERE` clause ORing a `set(N)` skip index predicate on a `LowCardinality(Nullable(String))` column with an `ngrambf_v1` predicate on a different column silently returned zero rows when the `LowCardinality(Nullable)` column contained only NULL values. `MergeTreeIndexConditionSet::traverseDAG` used to wrap every WHERE atom with `__bitWrapperFunc`. For `LowCardinality(Nullable(String)) = String` the atom result type is `LowCardinality(Nullable(UInt8))`, which the pre-fix wrapper coerced to `0` for NULL values, so the set index incorrectly concluded the granule could not match and the ORed `ngrambf_v1` side could not override the decision. PR ClickHouse#105384 detects that the atom result type is not integer after stripping `Nullable` and falls back to `UNKNOWN_FIELD`, keeping the granule. The new stateless test reproduces the smaller form reported by @den-crane on issue ClickHouse#105938 and asserts that the result with `use_skip_indexes = 1` matches the result with `use_skip_indexes = 0` (and the `assumeNotNull` workaround referenced in the issue). Verified locally that the test fails on a binary without ClickHouse#105384 (first SELECT returns `0`) and passes on master HEAD.
The first `SELECT count()` is the canonical bug trigger from ClickHouse#105938 / ClickHouse#105384. As written, the stateless runner randomizes `use_skip_indexes_on_data_read` and `use_skip_indexes_for_disjunctions` across runs. When either disables the partial-disjunction skip-index path in `MergeTreeDataSelectExecutor` / `ReadFromMergeTree`, the buggy `MergeTreeIndexConditionSet::traverseDAG` wrapping is never exercised and a pre-fix binary returns the same `100` as a post-fix binary, so the regression would silently slip through. Pin the four settings that gate the buggy path on that query directly via per-query `SETTINGS`, so the test always exercises the fix: use_skip_indexes = 1 use_skip_indexes_on_data_read = 0 use_skip_indexes_for_disjunctions = 1 use_query_condition_cache = 0 The other two queries are intentionally left alone: the second forces `use_skip_indexes = 0` as the no-index control, and the third uses `assumeNotNull(n)` so the atom result type is no longer `LowCardinality(Nullable(UInt8))` and the bug cannot trigger. Addresses bot review on PR ClickHouse#105990.
bd165b8 to
829f86d
Compare
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 331 line(s), 49 function(s) across 108 file(s) · Details Top files
|
Regression test that locks down #105384 against the smaller reproducer reported on issue #105938.
The bug: a
WHEREclause ORing aset(N)skip index predicate on aLowCardinality(Nullable(String))column with anngrambf_v1predicate on a different column silently returned zero rows when theLowCardinality(Nullable)column contained only NULL values. The same query withuse_skip_indexes = 0(or withassumeNotNullwrapped around the LC column) returned the correct count.Root cause:
MergeTreeIndexConditionSet::traverseDAGused to wrap every WHERE atom with__bitWrapperFunc. ForLowCardinality(Nullable(String)) = Stringthe atom result type isLowCardinality(Nullable(UInt8)). The pre-fix wrapper coerced a NULL granule value to0, so the set index incorrectly concluded the granule could not match and the ORedngrambf_v1side could not override the decision: the granule was pruned.The fix in #105384 detects that the atom result type is not integer after stripping
Nullable(note:removeNullabledoes not peel throughLowCardinality, soLC(Nullable(UInt8))falls into the non-integer branch) and falls back toUNKNOWN_FIELD, so the set index does not attempt to prune the granule and the query goes through the regular filter path. @Avogar identified #105384 as the canonical fix in #105938 (comment).Local validation:
100s.MergeTreeIndexConditionSet::traverseDAGis reverted: first SELECT returns0instead of100.Issue: #105938
Related fix PR: #105384
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add a regression test for the skip index OR +
LowCardinality(Nullable)wrong-result bug fixed by #105384.Documentation entry for user-facing changes
Version info
26.6.1.352