Repository navigation
Conversation
…rrayJoin(col) = c` `hasAll` with a float zero element did not use the index, because `FUNCTION_HAS_ALL` needs every hash in the granule while one of the two zeros is enough. A granule matches only if every predicate entry matches, and under `FUNCTION_HAS_ANY` an entry matches if any of its hashes does, so one entry per element, with both hashes for a zero, is exactly `hasAll`. `hasAll(a, [0.0, 42.0])` now skips granules without `42`. `arrayJoin(col) = constant` did not use the index for float elements, because `-0.0` equals `0.0` but hashes apart. With both zeros looked up, the `equals` arm now allows a float element with an integer or float constant. `convertFieldToType` converts it exactly or returns Null, in which case the index is not used, for example `0.1` against `Float32`. The `IN` arm still excludes floats.
Suggestions from the review of ClickHouse#123834: - `otherFloatZero` negates the zero instead of branching on its sign. - `BloomFilterHash::getFieldHash` returns the hash of a `Field` as `UInt64`, and `hashWithField` wraps it in a `ColumnConst`. The signed-zero helpers use it instead of building a `ColumnConst` per hash and reading it back with `getUInt`. - `hashWithColumnAndOtherZeros` adds the hash of a zero only when the constant array has the other zero but not this one, at most once, instead of once per zero element. `has_float_zero` stays set when both zeros are present, so `hasAll` still takes the per-element path. - `hasAll` with a zero element adds the predicate entry for zeros once, not once per zero element. `05327_bloom_filter_signed_zero_has_all_array_join` now also covers both zeros and repeated zeros in the constant array of `hasAny` and `hasAll`. Related: ClickHouse#123834 Co-authored-by: Copilot <[email protected]>
|
Could a maintainer add |
|
Workflow [PR], commit [a9e52d7] Summary: ❌
AI ReviewSummaryThis PR fixes signed-zero false negatives in Missing context / blind spots
Final VerdictStatus: ✅ Approve. No new inline findings; no existing threads require replies or status changes. |
…-zero-has-all-array-join # Conflicts: # src/Storages/MergeTree/MergeTreeIndexBloomFilter.cpp
This reverts commit cba98e5, which reverted ClickHouse#123834. The helpers keep the versions of this branch. `05325_bloom_filter_signed_zero` pins `basic` `Map` serialization: a bucketed `Map` does not find a `-0.0` key by `m[0.0]`, which is what failed with randomized `map_serialization_version_for_zero_level_parts = 'with_buckets'`, see ClickHouse#125713. Related: ClickHouse#125652
|
📊 Cloud Performance Report ✅ AI verdict: Baseline selected using StressHouse version hint 26.11.1.42530; measured build ancestry could not be verified. Measured differences are not attributed to this PR. ⚙️ Master level shift inside the baseline window (~2026-10-18 06:15:53): baseline for 1 query restricted to the checks matching the selected baseline era. no significant changes detected. K_source=6 K_base=26 flagged=0/65 clickbenchFlagged queries (5 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
…T ARRAY JOIN` `isDefaultAt` compares the bits, so a `-0.0` constant was not treated as the `+0.0` that `LEFT ARRAY JOIN` adds for an empty array. A granule with an empty and a nonempty array without zero holds neither zero hash, and the index skipped the padded rows matching `x = -0.0`.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 14 s compile time in total, 7 of them have a recent master baseline. |
…rray-join' into bloom-filter-signed-zero-has-all-array-join
…ition Use `accurateEquals` with the nested default so both signed zeros match padding, while nullable defaults retain their own semantics.
|
@groeneai can you review this and post review can you add a maintainer for visibility |
|
@groeneai can you do a first level of review |
groeneai
left a comment
There was a problem hiding this comment.
I reviewed 399c7b57 merged into current master (6ab09677, debug build), against a master build. The index logic looks correct to me; two requests below.
What I measured:
- #123744 reproduces on official 26.8.18.2 and 26.10.2.103 (
f = 0returns[3]with the index,[1,3]without). Both new tests fail on master and pass here. - 59 more queries comparing with and without the index on
Array(Float64),Array(Float32)andArray(LowCardinality(Float64))(NULL elements, three NaN bit patterns,inf,16777217,2^53 + 1, Int8/Int128/UInt256/Decimal/Bool/Nullable constants,indexOf,NOT,OR, emptyhasAll/hasAny): all equal here, 15 differ on master. - The new padding guard:
LEFT ARRAY JOIN ... WHERE x = <default>over granules mixing empty and nonempty arrays, for Int32, UInt8, Int128, Bool, String, FixedString(4) (''and'\0\0\0\0'), LowCardinality(String), LowCardinality(Nullable(String)), Date, DateTime, DateTime64, UUID, IPv4, IPv6, Float32, Float64, LowCardinality(Float64): 39 of 39 equal with and without the index, same as master.
1. Two changed lookups have no test. I reverted only the hashWithFieldAndOtherZero calls in the mapKeys branch of traverseTreeIn and in the m[k] = v path: 05325 and 05327 still pass, while on a bucketed map m[0.0] = 'x' and m[0.0] IN ('x') return [3] instead of [1,3]. On a basic map, m[0.0] with a Float64 key throws ILLEGAL_TYPE_OF_ARGUMENT, so these paths are reached only on a bucketed map, and feca3f9 dropped the two queries. #125713 is merged, and 05325 gives the same reference with both settings set to with_buckets, so the "does not find a -0.0 key by m[0.0] yet" comment is stale. A table pinned to buckets covers both:
CREATE TABLE t_bf_signed_zero_bucketed (id UInt64, m Map(Float64, String), INDEX idx_m mapKeys(m) TYPE bloom_filter GRANULARITY 1)
ENGINE = MergeTree ORDER BY id
SETTINGS index_granularity = 1, map_serialization_version = 'with_buckets', map_serialization_version_for_zero_level_parts = 'with_buckets';
INSERT INTO t_bf_signed_zero_bucketed VALUES (1, map(-0.0, 'x')), (2, map(0.5, 'x')), (3, map(0.0, 'x'));
-- m[0.0] = 'x' and m[0.0] IN ('x'), with and without the index: [1,3] [1,3] here, [3] [1,3] on master2. Changelog category. Against master this PR is again the #123744 fix, which is wrong results on 26.8 and 26.10. So I think it should be Bug Fix with Closes #123744, and the entry should say first that a bloom_filter lookup of 0.0 or -0.0 no longer skips granules holding the other zero. The table in the description compares with #123834, which is not on master. Optional: if the fix should be backported, the float arrayJoin(col) = c part could go to a separate PR so the backport carries only the fix.
I can't request reviewers on this repo, so for visibility: cc @Ergus, who reviewed #123834 and suggested the arrayJoin follow-up.
|
@groeneai I have added i.e. on master the index skips the SELECT arraySort(groupArray(id)) FROM t_bf_signed_zero_bucketed WHERE m[0.0] = 'x'; -- [1,3], [3] on master
SELECT arraySort(groupArray(id)) FROM t_bf_signed_zero_bucketed WHERE m[0.0] IN ('x'); -- [1,3], [3] on masterI have updated the description: the category is |
|
I re-checked a9e52d7 (debug build of master 312c31c + this PR):
On the split: backport scope is the maintainers' call. My view is that the signed-zero and Nothing else from my side. |
Closes #123744
Related: #123834
Related: #125652
Related: #125713
-0.0 = 0.0, but abloom_filterindex holds the hash of each value's bits, which differ for the two zeros. On master, a lookup of one zero skips the granules holding the other, sof = 0returns[3]with the index and[1,3]without (#123744).#123834 fixed this and was reverted in #125652, because
05325_bloom_filter_signed_zerofailed with randomizedmap_serialization_version_for_zero_level_parts = 'with_buckets'. The cause was in the bucketedMap, not in the index:m[0.0]did not find a-0.0key, which #125713 fixes. This PR reintroduces #123834 (commit "Reintroduce looking up both signed zeros in abloom_filterindex") and keeps the follow-up below.Change
0.0and-0.0(Look up both signed zeros in a bloom_filter index #123834).hashWithFieldAndOtherZeroadds the hash of the other zero for=,has,hasAny,mapContainsKey,mapContainsValue,mapKeys, and, on a bucketedMap,m[k] = vandm[k] IN (...).INon a float column compares bits, so it still looks up only the given zero.hasAllwith a float zero keeps pruning. Look up both signed zeros in a bloom_filter index #123834 makeshasAllwith a zero element not use the index, becauseFUNCTION_HAS_ALLneeds every hash in the granule while one of the two zeros is enough. A granule matches only if every predicate entry matches, and underFUNCTION_HAS_ANYan entry matches if any of its hashes does. So one entry per element, with both hashes for a zero, is exactlyhasAll.arrayJoin(col) = constantuses the index for float elements.bloomFilterHashDomainMatchesexcluded floats because-0.0equals0.0but hashes apart. With both zeros looked up throughhashWithFieldAndOtherZero, theequalsarm now allows a float element with an integer or float constant.convertFieldToTypeconverts it exactly or returns Null, in which case the index is not used, for example0.1againstFloat32. TheINarm still excludes floats.LEFT ARRAY JOINpadding.LEFT ARRAY JOINpads an empty array with the default value, which the index does not hold. A constant equal to that value, such as0.0or-0.0for a float element, does not use the index.On the 103 rows of
05327withindex_granularity = 1, the bloom filter selects these granules:has(a, 0)[0,101]instead of[0,100,101]hasAll(a, [-0.0])[100]instead of[0,100,101]hasAll(a, [0.0, 42.0])[101]instead of[100,101]arrayJoin(a) = 42arrayJoin(a) = 0.0arrayJoin(b) = 0.5,Float32arrayJoin(b) = 0.1,Float3205325_bloom_filter_signed_zerocompares each zero lookup with and without the index, includingm[0.0] = 'x'andm[0.0] IN ('x')on a table pinned to bucketedMapserialization, which return[3]instead of[1,3]on master.05327_bloom_filter_signed_zero_has_all_array_joindoes the same forhasAll,hasAnyandarrayJoin(col) = c, including-0.0/0.0,Float32and the inexact0.1, and checks withforce_data_skipping_indicesandmax_rows_to_readthat the index prunes. Both fail on master and pass here, also under randomized settings, and the bucketedm[0.0]queries give[1,3]withenable_analyzer = 0and1. Over 111arrayJoin(col) = c,hasAllandhasAnyqueries onArray(Float64),Array(Float32)andArray(LowCardinality(Float64)), with constants such as-0.0,nan,inf,0.1,16777217,9007199254740993,NULLand integers of different widths, the result with the index equals the result without it.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A
bloom_filterindex lookup of0.0or-0.0no longer skips granules that hold the other zero, which returned wrong results, for example forWHERE f = 0over a-0.0value. The index is also used forarrayJoin(arr) = constanton a float array column, and keeps skipping granules forhasAllwith a zero element, such ashasAll(arr, [0.0, 42.0]).Workflow [PR]
Sync PR [sync-upstream/pr/124045]