Repository navigation
Conversation
An Array bloom_filter index stores one hash per element, so a set array is looked up by its elements. An empty set array contributes no element, so no hash in a granule filter can stand for it, and a granule holding [] together with non-empty arrays is skipped even though it matches. WHERE x IN ([]) on Array(UInt32) therefore returned 0 rows instead of 1 at use_skip_indexes = 1, and WHERE x IN ([], [2]) returned 1 row instead of 2. Default settings; transform_null_in is not involved. The unsound shape is narrower than "the index column is an Array": it is "the set contains an empty array". A non-empty set array always contributes at least one element hash, so it is looked up soundly. Bailing out for every Array index would drop pruning that works today, so the guard declines pruning only when the set actually holds an empty array. Measured on 200k rows over 24 granules, an absent value is still pruned to 0/24 with the guard in place. notIn/globalNotIn are unaffected, because FUNCTION_NOT_IN inverts the mask and never skips a granule. The equals handler already refuses an Array index for the same reason.
…lookup
Suppressing only the `FUNCTION_IN` assignment is not enough. `traverseTreeIn`
accumulates every tuple component into one `RPNElement`, so with a single index
over both components the array component still appended its predicate and a
scalar sibling then set `FUNCTION_IN`, which re-enabled the unsound array
lookup:
CREATE TABLE t (x Array(UInt32), y UInt32,
INDEX idx_xy (x, y) TYPE bloom_filter GRANULARITY 1)
ENGINE = MergeTree ORDER BY tuple() SETTINGS index_granularity = 2;
INSERT INTO t VALUES ([], 1), ([1], 2), ([2], 3), ([3], 4);
SELECT count() FROM t WHERE (x, y) IN (([], 1), ([2], 3)); -- 1, expected 2
Contribute nothing from that component instead. The remaining components still
restrict the granule, so pruning is only weakened, never made unsound.
The earlier tuple arms used one index per column, where the array index never
sees the sibling that sets `FUNCTION_IN`, so they passed without covering this.
They are replaced by arms over a single `(x, y)` index in both component orders.
Read the array sizes through the public `ColumnArray::getSize` instead of
indexing the offsets directly.
|
Workflow [PR], commit [8fe1f26] Summary: ❌
AI ReviewSummaryThis PR fixes Final Verdict✅ No actionable findings in the current diff. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 17/18 (94.44%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units7 translation units recompiled, 12 s compile time in total, 7 of them have a recent master baseline. |
The keep-pruning control asserted `Granules: 0/N`, that is, that every granule
is skipped for an absent value. That is a property of the filter's false
positive draw rather than of the guard, and the draw is taken over however many
granules the part has. `index_granularity_bytes` is randomized in
[1024, 30Mi], and the table pins only `index_granularity`, so the same 200000
rows form anywhere from 25 to 3922 granules. Below about 160000 bytes some
granule takes a false positive and the assertion fails:
index_granularity_bytes granules skip index
1024 3922 171/3922
57942 69 3/69 <- the CI failure
163840 25 0/24
The draw has no margin even at a fixed layout: of twelve absent probe pairs
against the 8192-row layout, only seven skip every granule.
Assert instead what the control is for: the index is still reached for a set
with no empty array, and it still skips granules. An over-declining guard
returns no predicate, the condition becomes unknown, and the index drops out of
the plan with no `Skip` block at all, so the control still fails.
CI finish ledger - 8fe1f26Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
The failing step is
Not caused by this PR: the diff is Session id: cron:our-pr-ci-monitor:20260826-130000 |
cf7587e
Backport #116449 to 26.7: Fix `bloom_filter` index skipping granules for `IN` with an empty array in the set
Backport #116449 to 26.8: Fix `bloom_filter` index skipping granules for `IN` with an empty array in the set
Backport #116449 to 26.6: Fix `bloom_filter` index skipping granules for `IN` with an empty array in the set
… granules for `IN` with an empty array in the set
… granules for `IN` with an empty array in the set
… granules for `IN` with an empty array in the set
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a
bloom_filterskip index returning fewer rows forINon anArraycolumn when the set contains an empty array, for exampleWHERE x IN ([]).Description
Closes #116431.
An
Arraybloom_filterindex stores one hash per element, so a set array is looked up by its elements. An empty set array contributes no element, so no hash in a granule filter can stand for it, and a granule holding[]next to non-empty arrays is skipped even though it matches.Default settings;
transform_null_inis not involved. It also reaches a subquery set, a tupleINwith an array component, andArray(String)/Array(LowCardinality(String)).The unsound shape is narrower than "the index column is an
Array": it is "the set contains an empty array". A non-empty set array always contributes at least one element hash, so bailing out for everyArrayindex would drop pruning that works today. The guard therefore withholds the array predicate only when the set holds an empty array. It withholds the predicate rather than only theFUNCTION_INassignment becausetraverseTreeInaccumulates every tuple component into oneRPNElement, where a scalar sibling would otherwise re-enable the array lookup.notIn/globalNotInare unaffected:FUNCTION_NOT_INinverts the mask and never skips a granule. Theequalshandler already refuses anArrayindex for the same reason. This is thein/globalInsibling of thenullInguard added in #111329.Reproduced on 25.8.33.6 and 26.3.23.7. Validated with builds of this branch and its base differing only by this patch: 9 of the new test's assertions fail on the base, and an absent value still prunes to
Granules: 0/24over 200k rows.Workflow [PR]
Sync PR [sync-upstream/pr/116449]
Version info
26.9.1.453(included in26.9and later)26.8.2.5,26.7.6.54,26.6.4.63