Skip to content

Docs: rewrite the JOIN clause reference as syntax and semantics, and add a JOIN Settings page - #129276

Merged
ayakovlev-clickhouse merged 9 commits into
masterfrom
docs-join-reference-rewrite
Nov 6, 2026
Merged

ayakovlev-clickhouse merged 9 commits into
masterfrom
docs-join-reference-rewrite

Conversation

@ayakovlev-clickhouse

@ayakovlev-clickhouse ayakovlev-clickhouse commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

The JOIN documentation was reorganized into a conceptual overview, an execution page, an algorithms page, a memory and spilling page, and a best-practices page. The JOIN clause reference still carried its own copies of execution, memory, and performance advice, part of which was outdated or wrong. This change reduces the reference to syntax and semantics, links to the concept pages instead of repeating them, corrects the claims that no longer hold, and adds a complete table of the session settings that affect JOINs.

The body of docs/reference/statements/select/join.mdx is generated between AUTOGENERATED_START and AUTOGENERATED_END from documentation["JOIN"] in src/Parsers/ParserTablesInSelectQuery.cpp.

Summary of changes

  • src/Parsers/ParserTablesInSelectQuery.cpp: new body of the JOIN reference, in this order: introduction and syntax with a scope paragraph, supported types of JOIN with the cross_to_inner_join_rewrite values, ON section conditions, inequality conditions, arbitrary ON condition, NULL and NaN values in JOIN keys, implicit type conversion, ASOF JOIN usage, PASTE JOIN usage, LATERAL JOIN, distributed JOIN, usage recommendations (processing of empty or NULL cells, syntax), examples, settings, related content.
  • docs/concepts/features/operations/select/join-settings.mdx (new): "JOIN Settings", a hand-written page with five tables of the session settings that affect JOINs. docs/concepts/navigation.json lists it in the JOINs section after "JOIN memory management and spilling". The tables are on a separate page because they made the JOIN documentation string 65698 bytes long, above the 65536 bytes that C++ compilers are required to support
  • docs/concepts/features/operations/select/join-memory-management.mdx: the "Hard limits" section now describes enable_adaptive_memory_spill_scheduler and legacy_join_size_limits_trigger_spilling, which were previously described only on the reference page.

Moved and removed content

Content New location
"Usage recommendations > Performance" (planner order, caching, IN, dictionaries) Removed. The planner is covered by How ClickHouse executes JOINs. IN, dictionaries and the Join table engine are covered by Minimize and optimize JOINs. The reference links to these pages in the introduction and in "Related content".
"Usage recommendations > Memory limitations" Removed. Covered by JOIN memory management and spilling. The descriptions of enable_adaptive_memory_spill_scheduler and legacy_join_size_limits_trigger_spilling were added to its "Hard limits" section.
"Usage recommendations > Syntax" (USING rules) Kept under the same heading and rewritten. The rule "the other columns must be named differently" is false and was replaced by the actual resolution of same-named columns. The rule "the list of columns is set without brackets" was replaced by "with or without parentheses". The rule "more complex join conditions are not supported" is now "only column names, no expressions".
"Usage recommendations > Processing of empty or NULL cells" Kept under the same heading and extended: the two values of join_use_nulls, types that cannot be Nullable (for example Array) keep their type, and the merged USING column of a FULL JOIN becomes Nullable. The NULL key rule links to "NULL and NaN values in JOIN keys" instead of repeating it.
"Usage recommendations > Syntax Limitations" Removed. All four previous claims are false with the analyzer, verified during internal testing
"Implicit type conversion" Rewritten. The UInt64/Int64 example of a failing conversion is outdated since 26.9 and was replaced by the rules for the common supertype, the common-subtype conversion and the NO_COMMON_TYPE error. The existing example was kept with ORDER BY ALL.
semi_join_include_columns_from_both_sides note The qualifier "When using the analyzer" was removed, because the analyzer is always enabled since 26.9.
LATERAL JOIN Moved after PASTE JOIN usage. Content kept. The setting name is enable_lateral_join, and the version of arrival is added.
partial_merge note Replaced by one sentence that links to Supported JOIN types per algorithm.
OR execution paragraph Reduced to one sentence that links to hash.
"JOIN with an arbitrary ON condition > Performance" Reduced to two sentences that link to Block nested loop fallback and to JOIN memory management and spilling.
"Settings" section and its "See also" list Replaced by five settings tables under #settings.
"Additional JOIN types" table Added a row for INNER JOIN LATERAL and LEFT JOIN LATERAL, which were missing. Verified on 26.11.1.1307: JOIN LATERAL, INNER JOIN LATERAL, and LEFT [OUTER] JOIN LATERAL work. RIGHT, FULL, CROSS, comma, and ANY forms are rejected. Without enable_lateral_join = 1, the query fails with SUPPORT_IS_DISABLED.
cross_to_inner_join_rewrite paragraph Rewritten as the subsection "Rewriting CROSS JOIN as INNER JOIN" (#cross-join-rewrite) under "Supported types of JOIN".
Example over test.hits and test.visits Replaced by a self-contained example over VALUES, with output.

Settings list

The tables contain 110 settings. The list was built by searching system.settings on 26.11.1.1307 for join, lateral, global_in and distributed_product in the name or description, reading each declaration in src/Core/Settings.cpp, and adding the settings that the five concept and best-practices pages mention.

Changelog category (leave one):

  • Documentation (changelog entry is not required)

Changelog entry (a [user-readable short description])

Not required.


Workflow [PR]
Sync PR [sync-upstream/pr/129276]

Version info

  • Merged into: 26.11.1.1524-master (included in 26.11 and later)

@mintlify

mintlify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Nov 4, 2026, 2:58 PM

@clickhouse-gh

clickhouse-gh Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8ae50dd]

Summary: ✅


AI Review

Summary

This documentation change reorganizes the JOIN reference around syntax and semantics, adds a settings index, and moves memory guidance into the concept pages. The earlier type-conversion findings are addressed. One new omission needs correction: the settings index drops an existing warning about a result-changing optimization.

Findings

⚠️ Majors

  • docs/concepts/features/operations/select/join-settings.mdx:85: Preserve the correctness warning for query_plan_convert_join_to_in. The implementation of tryConvertJoinToIn accepts ALL strictness and turns the right input into a set, discarding duplicate matches. A left row matching two right rows therefore appears once instead of twice. The new description omits the existing warning in src/Core/Settings.cpp and the linked reference. State that the option is disabled by default and can change results for non-ANY joins.
Missing context / blind spots
  • ⚠️ The public playground rejected the runtime comparison because its read-only policy prevents changing the required settings. The finding is supported by the conversion code at the PR head and the existing setting documentation; running a duplicate-key join with the option disabled and enabled would provide runtime confirmation.
Final Verdict

⚠️ Request changes — restore the result-changing warning in the new settings table.

@clickhouse-gh clickhouse-gh Bot added the pr-documentation Documentation PRs for the specific code PR label Nov 4, 2026
@ayakovlev-clickhouse

ayakovlev-clickhouse commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

@clickhouse-gh clickhouse-gh Bot added the comp-documentation Documentation (docs, examples, READMEs). label Nov 4, 2026
ayakovlev-clickhouse and others added 2 commits November 4, 2026 15:21
The common-subtype conversion applies only to integer keys and tuples of
integer keys. The merged USING column of a SEMI or ANTI JOIN keeps the type
of the preserved table when semi_join_include_columns_from_both_sides or
anti_join_include_columns_from_both_sides is disabled.

Addresses the review of #129276

Co-authored-by: Cursor <[email protected]>
The settings tables made the documentation string of the `JOIN` clause
65698 bytes long, above the 65536 bytes that C++ compilers are required to
support, and the build failed with `-Woverlength-strings`. The tables now
live on the new page `JOIN Settings` in the JOINs section, and the
`#settings` section of the reference links to it.

https: //github.com/ClickHouse/ClickHouse/actions/runs/41847167721/job/126634685869?pr=129276
https: //github.com//pull/129276
Co-authored-by: Cursor <[email protected]>
@ayakovlev-clickhouse ayakovlev-clickhouse changed the title Rewrite the JOIN clause reference as syntax and semantics, with a complete table of JOIN settings Rewrite the JOIN clause reference as syntax and semantics, and add a JOIN Settings page Nov 4, 2026
@dhtclk
dhtclk requested review from dhtclk and mikelewisCH November 4, 2026 15:23
@clickhouse-gh

clickhouse-gh Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 8ae50dd2c with master 3f4c5742e (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 7 s compile time in total, 7 of them have a recent master baseline.

Job report

@ayakovlev-clickhouse ayakovlev-clickhouse changed the title Rewrite the JOIN clause reference as syntax and semantics, and add a JOIN Settings page Docs:Rewrite the JOIN clause reference as syntax and semantics, and add a JOIN Settings page Nov 5, 2026
@ayakovlev-clickhouse ayakovlev-clickhouse changed the title Docs:Rewrite the JOIN clause reference as syntax and semantics, and add a JOIN Settings page Docs: rewrite the JOIN clause reference as syntax and semantics, and add a JOIN Settings page Nov 5, 2026
huldarchen pushed a commit to huldarchen/ClickHouse that referenced this pull request Nov 5, 2026
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]>

@mikelewisCH mikelewisCH left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. The updated organization of info is a big improvement, here.

Approved, with non-blocking feedback for your consideration:

  • On the diff: wording suggestions on ie_join, suggestions re. headings Usage recommendations and Syntax, and suggestions on links in the intro vs. Related content.
  • The PR description points to "the fact checks" as the basis for removing ### Syntax Limitations but it's not clear what those are. Consider referencing in a way that internal colleagues can find it, or just saying "internal testing" without referring.

@ayakovlev-clickhouse

Copy link
Copy Markdown
Contributor Author

Thanks for the review @mikelewisCH , applied all the changes.

@ayakovlev-clickhouse
ayakovlev-clickhouse added this pull request to the merge queue Nov 6, 2026
Merged via the queue into master with commit 96face4 Nov 6, 2026
187 checks passed
@ayakovlev-clickhouse
ayakovlev-clickhouse deleted the docs-join-reference-rewrite branch November 6, 2026 14:14
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-documentation Documentation (docs, examples, READMEs). pr-documentation Documentation PRs for the specific code PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants