Skip to content

Fix ANY RIGHT JOIN - #102893

Merged
nickitat merged 9 commits into
masterfrom
fix_any_right_join
Apr 28, 2026
Merged

nickitat merged 9 commits into
masterfrom
fix_any_right_join

Conversation

@nickitat

@nickitat nickitat commented Apr 16, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixed possible incorrect result of ANY RIGHT JOIN.


Closes: #102208

Version info

  • Merged into: 26.5.1.141

@clickhouse-gh

clickhouse-gh Bot commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5f76cd9]

Summary: ✅


AI Review

Summary

The PR fixes ANY RIGHT JOIN behavior for multi-disjunct (OR) hash-join paths by avoiding early termination in the affected branch, and adds focused regression coverage plus a broader hash-join stress suite. I did not find correctness, safety, or performance regressions in the proposed change.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Apr 16, 2026
@yariks5s yariks5s self-assigned this Apr 16, 2026
nickitat and others added 2 commits April 16, 2026 16:30
The `FULL JOIN: multi key` query used `ORDER BY coalesce(l.k1, r.k1),
coalesce(l.k2, r.k2)`, but with `join_use_nulls=0` unmatched right rows
get default `l.k1=0, l.k2=''` instead of NULL. Both unmatched right rows
collapsed to sort key `(0, '')`, so output order varied by plan.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102893&sha=79e6b5bd06032c3b82a3fd2251005e9a733b5447&name_0=PR&name_1=Stateless+tests+%28amd_debug%2C+distributed+plan%2C+s3+storage%2C+parallel%29
PR: #102893

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-authored-by: Nikita Taranov <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.00% 84.00% +0.00%
Functions 91.10% 91.10% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 100.00% (3/3) · Uncovered code

Full report · Diff report

@nickitat
nickitat added this pull request to the merge queue Apr 28, 2026
Merged via the queue into master with commit c2fb57f Apr 28, 2026
325 of 326 checks passed
@nickitat
nickitat deleted the fix_any_right_join branch April 28, 2026 08:31
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 28, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Hi — this PR may need backporting to 26.3 (LTS), 26.2, 26.1, 25.8 (LTS), but no backport label was found.

Affected code: HashJoinMethods::joinRightColumns multi-disjunct variant, src/Interpreters/HashJoin/HashJoinMethodsImpl.h:661 — introduced in 25.8.

Why: Wrong-results bug in ANY RIGHT JOIN with OR disjuncts. The buggy is_any_or_semi_join break predicate in joinRightColumns was introduced in PR #82308 (HashJoin main loop optimization, merged 2025-06-30 per CIDB). All currently supported release branches (25.8 lts released 2025-08-29 and later) contain the bug.

If this should be backported, consider adding pr-must-backport or a version-specific label (e.g. v26.3-must-backport). Ignore this if backporting is not applicable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default 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.

Premature break in multi-disjunct joinRightColumns causes ANY RIGHT JOIN with OR conditions to miss matches

4 participants