Repository navigation
Fix flaky test 01550_create_map_type - #101887
alexey-milovidov merged 2 commits into
Conversation
|
Pre-PR Validation Gate (session: a) Deterministic repro: Yes — b) Root cause: With bucketed serialization (strategy=constant, min_avg_size=1), even 2-key maps get bucketed. Keys are stored in bucket order (alphabetical: c) Fix matches root cause: Pins d) Test intent preserved: Yes — the test still exercises Map type creation, key access, equality filtering, aggregation, and type conversions. Only the serialization format is pinned to avoid the comparison bug. e) Both directions: ✅ Without fix + CI settings → missing |
|
cc @CurtizJ — could you review this? Pins map_serialization_version to basic on one MergeTree table in test 01550 that uses |
|
@groeneai, fix the test properly: allow different serializations, but compare up to the order of keys. |
Use mapSort() to compare maps up to key order instead of pinning map_serialization_version. With bucketed serialization, Map keys may be stored in bucket order rather than insertion order, causing direct equality (=) to return wrong results. mapSort() normalizes both sides to the same key ordering before comparison.
5f613e8 to
281529c
Compare
|
@alexey-milovidov Updated. Replaced the -- before (breaks when bucketed serialization reorders keys):
select b from table_map where a = map('name','lisi', 'gender', 'female');
-- after (normalizes key order before comparison):
select b from table_map where mapSort(a) = mapSort(map('name','lisi', 'gender', 'female'));The CREATE TABLE is back to its original form — no pinned settings. All serialization variants are now allowed, and the comparison is order-independent. Verified both directions locally:
(session: |
|
Workflow [PR], commit [e8fa3e3] Summary: ✅ AI ReviewSummaryThis PR updates ClickHouse Rules
Final Verdict
|
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.
Use mapSort() to normalize Map key ordering in SELECT output. The CI randomizer can set map_serialization_version='with_buckets' on MergeTree tables. Bucketed serialization distributes Map keys across hash buckets, which changes key display order on read. This causes SELECT * on Map columns to produce output that doesn't match the reference file. PR ClickHouse#101887 already fixed the WHERE comparison (mapSort on both sides). This extends the same approach to SELECT * queries and the CAST expression that also display Map values. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
...
What this PR does
With randomized
map_serialization_version = with_buckets, Map keys may be stored in bucket order rather than insertion order. The test'sWHERE a = map(...)comparison failed because the Map=operator compares internal binary representations — a stored bucketed map ≠ a literal basic-format map.Instead of pinning serialization settings, uses
mapSort()on both sides of the comparison to normalize key order, making the equality check order-independent while still allowing all serialization variants to be tested.Version info
26.4.1.596