Repository navigation
Fix flaky test 03399_mapContains_functions - #101541
Conversation
Pin map_serialization_version and map_serialization_version_for_zero_level_parts to 'basic' in the CREATE TABLE settings to prevent randomized 'with_buckets' serialization from reordering Map keys by hash bucket. The test verifies mapContainsValueLike/mapExtractValueLike function behavior, not Map serialization format. When CI randomizes map bucketing settings (with_buckets + constant strategy + min_avg_size=1), keys get reordered by hash bucket, causing the output to differ from the reference file. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Pre-PR Validation GateSession: a) Deterministic repro? ✅ Yes. CREATE TABLE t (id UInt32, map Map(String, String)) Engine=MergeTree() ORDER BY id
SETTINGS index_granularity=2, map_serialization_version='with_buckets',
map_serialization_version_for_zero_level_parts='with_buckets',
max_buckets_in_map=17, map_buckets_strategy='constant', map_buckets_min_avg_size=1;
INSERT INTO t VALUES (1, {'1-K1':'1-V1','1-K2':'1-V2'});
SELECT * FROM t;
-- Output: 1 {'1-K2':'1-V2','1-K1':'1-V1'} (keys reversed)b) Root cause explained? ✅ c) Fix matches root cause? ✅ Pins d) Test intent preserved? ✅ The test verifies e) Both directions demonstrated? ✅
|
|
cc @Avogar — could you review this? It pins map serialization to 'basic' in the CREATE TABLE settings to prevent randomized bucketed Map serialization from reordering keys in the test output (the test verifies mapContainsValueLike/mapExtractValueLike, not serialization format). |
|
Workflow [PR], commit [ab326f7] Summary: ❌
AI ReviewSummaryThis PR makes ClickHouse Rules
Final Verdict
|
|
The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix. |
820fa46
Replace map_serialization_version settings pins in CREATE TABLE with mapSort() wrapping in SELECT queries, making the test output order-independent when CI randomizes map_serialization_version to 'with_buckets'. This aligns with the approach used in PRs ClickHouse#101541 and ClickHouse#101887 per reviewer feedback.
The test creates MergeTree tables with a Map(LowCardinality(String), String)
column and reads the Map back to check that CREATE TABLE AS preserves the column
type and that CHECK TABLE passes. It does not check the Map key order.
CI randomizes map_serialization_version_for_zero_level_parts to 'with_buckets',
which stores Map keys in hash-bucket order in zero-level parts instead of
insertion order. Reading the Map back then yields a reordered Map
({'attr_3':'value_3','attr_2':'value_2'} instead of the inserted order), which
differs from the reference.
Pin map_serialization_version and map_serialization_version_for_zero_level_parts
to 'basic' on both tables so the stored order stays the insertion order. Same
approach as the merged fixes for 03399_mapContains_functions (ClickHouse#101541) and
02030_function_mapContainsKeyLike (ClickHouse#101538).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
The test creates MergeTree tables with a Map(LowCardinality(String), String)
column and reads the Map back to check that CREATE TABLE AS preserves the column
type and that CHECK TABLE passes. It does not check the Map key order.
CI randomizes map_serialization_version_for_zero_level_parts to 'with_buckets',
which stores Map keys in hash-bucket order in zero-level parts instead of
insertion order. Reading the Map back then yields a reordered Map
({'attr_3':'value_3','attr_2':'value_2'} instead of the inserted order), which
differs from the reference.
Pin map_serialization_version and map_serialization_version_for_zero_level_parts
to 'basic' on both tables so the stored order stays the insertion order. Same
approach as the merged fixes for 03399_mapContains_functions (ClickHouse#101541) and
02030_function_mapContainsKeyLike (ClickHouse#101538).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pin
map_serialization_versionandmap_serialization_version_for_zero_level_partstobasicin the test'sCREATE TABLEsettings to prevent randomizedwith_bucketsserialization from reordering Map keys by hash bucket.The test verifies
mapContainsValueLike/mapExtractValueLikefunction behavior, not Map serialization format. When CI randomizes map bucketing settings (with_buckets+constantstrategy +min_avg_size=1), keys get stored in hash-bucket order instead of insertion order, causing the output to differ from the reference file.Root cause:
map_serialization_version_for_zero_level_parts='with_buckets'combined withmap_buckets_strategy='constant'andmap_buckets_min_avg_size=1reorders Map keys by hash bucket in zero-level parts (directly from INSERT). Rows where the hash-bucket order differs from insertion order produce reversed keys (e.g.,{'1-K2':'1-V2','1-K1':'1-V1'}instead of{'1-K1':'1-V1','1-K2':'1-V2'}).CIDB evidence: 11 failures across 8 distinct PRs + master in 30 days.
Verification: 50/50 passes with full randomization after fix. Deterministic reproduction confirmed in both directions.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
Version info
26.4.1.586