Repository navigation
Find both signed zeros in a key subcolumn of a bucketed Map - #125713
Conversation
A bucketed `Map` puts a key into the bucket of the hash of its bits, and `m[k]` read only the bucket of `k`, so `m[0.0]` did not find a `-0.0` key in another bucket. A key with a float zero, also inside a `Tuple` or an `Array`, now reads the whole `Map`. This made `05325_bloom_filter_signed_zero` fail with `map_serialization_version_for_zero_level_parts = 'with_buckets'`: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=40fc4717e5517a27aa1a01fb9c78ca91a2bb8c40&name_0=MasterCI&name_1=Stateless+tests+%28arm_binary%2C+ParallelReplicas%2C+s3+storage%2C+parallel%29 Related: ClickHouse#123834
|
@Algunenano, this is the cause of the @alexey-milovidov, #115970 includes the |
|
Workflow [PR], commit [21964f2] Summary: ✅
AI ReviewSummaryThis PR fixes signed-zero lookups in bucketed Missing context / blind spots
Final VerdictStatus: ✅ Approve. No review changes requested; remaining CI must pass. |
The check for a float zero in a key of `m[k]` did not enter an `Object`, so a `JSON` key with a zero in a path read only one bucket. Use `anyFieldSatisfies`, which enters `Tuple`, `Array`, `Map` and `Object`. Related: ClickHouse#125713 (comment)
|
@harikrishnan94 could I get a review on this PR |
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
The local `isFloatZero` duplicated `isFloatZeroField` from `Field.h`, which came with master after this branch was started. The comments of `getDynamicSubcolumnInfo` now say that a key with a float zero reads the whole `Map`, and split the long sentence about the bucket of a key. Co-authored-by: harikrishnan.prabakaran <[email protected]>
The only caller, `DataTypeMap::getDynamicSubcolumnInfo`, passes `read_whole_map` explicitly. Co-authored-by: harikrishnan.prabakaran <[email protected]>
…le `Map` With `read_whole_map`, `map_nested_serialization` and `nested_type` hold the whole `Map` serialization and the `Map` type, and all buckets are read. The comments still described `Array(Tuple(K, V))` and a read of one bucket. Co-authored-by: harikrishnan.prabakaran <[email protected]>
The test compares `ReadCompressedBytes` of `m[3.0]`, which reads one bucket, and `m[0.0]`, which reads all buckets. Both lookups also print their sums, so a wrong result fails the test too. The tests of the results are in `05395_map_buckets_signed_zero_key`. Co-authored-by: harikrishnan.prabakaran <[email protected]>
|
@harikrishnan94 I have rebased the branch with master, staleness tests were failing, can you please reapprove |
…o key of a bucketed `Map` CI picks `serialization_info_version` at random. With `basic`, a `Map` is written without buckets whatever `map_serialization_version` says. Then `m[3.0]` and `m[0.0]` read the same bytes, and `05407_map_buckets_zero_key_read_volume` failed in about half of the runs. `05395_map_buckets_signed_zero_key` did not test a bucketed `Map` in those runs either. Set `serialization_info_version = 'with_types'` in the tables of both tests, as the other tests of a bucketed `Map` do. Co-authored-by: Cursor <[email protected]>
There was a problem hiding this comment.
Thanks @aschoube. No action item is needed from your side. Once CI run is complete and it becomes green the PR will be automatically merged
Build profile diff (arm_release)Commit See the job log for details. |
|
@harikrishnan94 Are you looking into the flakiness or do you want me to check this ? |
With parallel replicas, the replicas split the reading, so `ReadCompressedBytes` of a query varies. In 2 of 150 runs in `Stateless tests (arm_binary, ParallelReplicas, s3 storage, parallel)`, `m[0.0]` read only 4068 and 1839 bytes and the check that it reads more than twice the bytes of `m[3.0]` failed. Set `enable_parallel_replicas = 0` in the first `SET` of the test. Co-authored-by: Cursor <[email protected]>
…e lookup of a zero key in all buckets The previous commit was wrong: the `CH Inc sync` failure (ClickHouse/clickhouse-private#70376) is not specific to `SharedMergeTree`. It reproduces locally after merging `master`, which now reads all buckets of a bucketed `Map` for a key with a floating point zero (#125713), so `m[0.]` finds the key `-0.`. Remove the tag and update the comment and the reference. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`count(DISTINCT)`, `uniq*`, `SELECT DISTINCT`, `arrayDistinct` and hash
`JOIN` identify a row by the SipHash of `IColumn::updateHashWithValue`
alone. `ColumnObject::updateHashWithValue` hashed every path without its
size and every object without its number of paths, and
`ColumnDynamic::updateHashWithValue` hashed the type name without its
size. Different values could therefore give the same byte stream:
the paths of adjacent objects of an `Array(JSON)` ran together
(`[{a},{b,c}]` vs `[{a,b},{c}]`, ClickHouse#129458), a path ran into the type name
after it (`x` + `UInt64` vs `xU` + `Int64`), and in `Dynamic` a type
name ran into the value (`Date` + `32` vs `Date32`). The framing dates
from ClickHouse#69203; `GROUP BY` was correct because it keys on the arena
serialization, which writes the count and every size.
Now the object hash starts with the number of paths, as
`serializeDynamicPathsAndSharedDataIntoArena` computes it, every path is
preceded by its size, and a non-NULL `Dynamic` value hashes a zero tag,
the size of the type name and the name. The tag differs from the
`NULL_DISCRIMINATOR` hashed for NULL. One helper,
`ColumnDynamic::updateHashWithTypeName`, is used for dynamic paths and
for shared data, so the hash stays independent of where a path is
stored.
Bucketed `Map` parts place a key in bucket `SipHash(key) % N`, and a
`m[key]` lookup reads only that bucket, so the new hash would miss keys
with `JSON` or `Dynamic` written by an older version, and an older
version would miss keys written by this one. Such a `Map` is now read
whole (the guard ClickHouse#125713 added for float zeros) and written in one
bucket, which every version reads whole.
Hash values of `JSON` and `Dynamic` rows change, so `uniq*` states of
such arguments stored by older versions do not deduplicate against new
ones. `sipHash64` of `JSON` uses `serializeForHashCalculation` and is not
changed.
Closes ClickHouse#129458
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #123834
Related: #125652
Related: #115970
A bucketed
Map(map_serialization_version = 'with_buckets') puts each key into the bucket of theSipHashof its bits, andm[k]reads only the bucket ofk.-0.0 = 0.0, but the bits of the two zeros differ, som[0.0]does not find a-0.0key in another bucket, and the other way around:With
map_serialization_version = 'basic'both columns areaandb. It reproduces on 26.9.17.8: https://fiddle.clickhouse.com/6747c5fc-cdf8-4b4d-aa3c-f546426fee3bThe same happens for
Float32keys and for a zero inside aTuple, anArrayor a path of aJSONkey. This is why05325_bloom_filter_signed_zerofrom #123834 failed with the randomizedmap_serialization_version_for_zero_level_parts = 'with_buckets':m[0.0] = 'x'returned[3]with and without the index.Change
DataTypeMap::getDynamicSubcolumnInfochecks whether the key holds a float zero (also inside aTuple, anArray, aMapor a path of aJSON). For such a key in a bucketedMap,SerializationMapKeyValuereads the wholeMapthroughSerializationMap, which restores the order of the keys from the bucket index, and then extracts the key as usual. So a map with both zeros returns the value of the first one, as withbasic. Nothing changes in what is written, so existing parts work as they are. Other keys still read only their bucket.A key with a float zero now reads all buckets and the bucket index. On 200k rows with 16 keys per map and 8 buckets in a wide part,
m[3.0]opens 9 files and reads 1.7 MB, andm[0.0]opens 53 files and reads 12.5 MB. Abasictable reads 2.8 MB in 6 files for either key.Hashing
-0.0as0.0on write would not be enough, because existing parts already have-0.0in its own bucket.Test
05395_map_buckets_signed_zero_keychecksm[0.0],m[-0.0], a non-zero key,Float32,Tuple,ArrayandJSONkeys, a map with both zeros, and a filter onm[0.0]. The reference is the output withmap_serialization_version = 'basic'. On master it returns:05407_map_buckets_zero_key_read_volumechecks thatm[0.0]reads more than twice the compressed bytes ofm[3.0], and that both return the right sums.Locally, the new test passed 60 runs with randomized settings.
05325_bloom_filter_signed_zerowith the culprit settings from the master failure (map_serialization_version_for_zero_level_parts = 'with_buckets',map_buckets_strategy = 'constant',map_buckets_min_avg_size = 1) fails without this change and passes with it, and it passed 60 randomized runs. The otherMapsubcolumn,Mapbucket andMapbloom filter tests pass. The only failures were caused by the local hostname.The failing master run: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=40fc4717e5517a27aa1a01fb9c78ca91a2bb8c40&name_0=MasterCI&name_1=Stateless+tests+%28arm_binary%2C+ParallelReplicas%2C+s3+storage%2C+parallel%29
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a bucketed
Map(map_serialization_version = 'with_buckets') wherem[0.0]did not find the key-0.0, andm[-0.0]did not find the key0.0. The same applied to a zero inside aTuple,ArrayorJSONkey.Workflow [PR]
Sync PR [sync-upstream/pr/125713]
Version info
26.11.1.328-master(included in26.11and later)