Repository navigation
Docs: how each JOIN algorithm evaluates an equality in the ON clause - #129361
Conversation
Add a "Comparison of JOIN keys" section to the JOIN algorithms page and point the `ie_join` and block nested loop sections at it. A JOIN key is compared by the algorithm, not by `equals`. The hash family compares `Float` keys by their bits, so a `NaN` matches only a `NaN` with the same bit pattern; the sort-merge family compares with `IColumn::compareAt`, where any two `NaN` are equal; both match a `Tuple` with a `NULL` element and a `NULL` `Variant`, for which `equals` returns `NULL`. `ie_join` evaluates a remaining equality as a residual filter or post-join filter with `equals`, and the block nested loop fallback evaluates the whole `ON` condition, so neither matches those pairs. Measured per algorithm on master (26.11.1.1) with one row on each side. `-0.0` vs `0.0` and a `String` with trailing zero bytes vs `FixedString` are left out on purpose: ClickHouse#115970 and ClickHouse#118561 remove those differences. The JOIN statement page is not edited because ClickHouse#129276 rewrites it. Related: ClickHouse#129219 Related: ClickHouse#112409 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…erge JOINs The set filter that `max_rows_in_set_to_optimize_join` adds before the sorts of a `full_sorting_merge` JOIN compares keys by bits and applies only to blocks that arrive after the other side's set is complete, so `NaN` keys with different bit patterns match in some runs and not in others. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…N keys in direct JOINs A dictionary that fetches the requested keys from its source writes them into a text query, where every `NaN` becomes `nan`, so a `direct` JOIN into it matches only the bit pattern of `nan`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s to the source as text The `complex_key_ssd_cache` layout fetches missing keys through the same `CacheDictionary` path as `complex_key_cache`, so a `direct` JOIN into it also matches only the bit pattern of `nan`. Also split the paragraph below the key comparison table into three. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Internal second-model review (click to expand)
|
|
cc @Blargian, could you review this and add the |
|
Workflow [PR], commit [e987a52] Summary: ✅ AI ReviewSummaryThis documentation change explains how Final VerdictStatus: ✅ Approve |
d7a894a
ClickHouse#129219 concluded that `ie_join` should not yield to another algorithm when a residual `equals` differs from a join key: the remaining differences (`NaN`, `NULL` inside tuples) are documented per algorithm in ClickHouse#129361, and ClickHouse#118561 makes `String`/`FixedString` keys, including `ie_join` range keys, compare like the scalar functions. The `hash` requirement for merging ranges now states its actual reason: a merged range is a non-equi `ON` condition. Add the `String`/`FixedString` regressions from the review of ClickHouse#128140, and drop the `parallel_hash` case: `parallel_hash` is now the same algorithm as `hash`. Related: ClickHouse#129219 Related: ClickHouse#128140
Drop the `String`/`FixedString` cases (fixed in master by ClickHouse#118561), the `NaN`/`Tuple(Nullable)` key cases (documented per algorithm in ClickHouse#129361), and the reorder cases that repeat one query under other join or reorder algorithms. Shorten the comment of the performance test.
Related: #129219
Related: #112409
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
@ vdimir asked on #129219 to document, per JOIN algorithm, where an
ONequality used as a JOIN key differs fromequals, since the same query can return different rows depending onjoin_algorithm.Adds a "Comparison of JOIN keys" section to the JOIN algorithms page and points the
ie_joinand block nested loop sections at it. As a key, twoNaNvalues match (the hash family only for the same bit pattern), as do two(1, NULL)tuples and twoNULLVariantvalues.ie_joinand the block nested loop fallback useequalsand match none of them. The section also notes two cases where theNaNcell depends on more than the algorithm: adirectJOIN into a dictionary that reads the keys from aCLICKHOUSEsource matches only the bit pattern ofnan, and with a non-zeromax_rows_in_set_to_optimize_join, whetherfull_sorting_mergematches twoNaNvalues with different bit patterns can vary from run to run.-0.0andString/FixedStringpadding are left out: #115970 and #118561 remove those differences. The JOIN statement page is untouched because #129276 rewrites it.Validation: I measured every cell on master (26.11.1.1), one row per side, for each
join_algorithmvalue, the block nested loop fallback,direct(dictionary,EmbeddedRocksDB,MergeTree), theJoinengine andASOF.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/129361]
Version info
26.11.1.1414-master(included in26.11and later)