Skip to content

Backport #112921 to 26.7: Evaluate randomHadamardTransform once for a constant vector - #114564

Merged
clickhouse-gh[bot] merged 2 commits into
26.7from
backport/26.7/112921
Aug 14, 2026
Merged

clickhouse-gh[bot] merged 2 commits into
26.7from
backport/26.7/112921

Conversation

@robot-clickhouse-ci-1

@robot-clickhouse-ci-1 robot-clickhouse-ci-1 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Original pull-request #112921

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.7.4.41

@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backport Changes, backported to release branch. Do not use manually - automated use only! label Aug 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [899ae2a]

Summary: ✅

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 The single red on da0f9d46 — Stateless tests (amd_asan_ubsan, distributed plan, parallel) / 03571_join_inequality_constants — is unrelated to this backport (which only touches src/Functions/randomHadamardTransform.cpp and adds 04660_random_hadamard_transform_constant_folding).

The harness randomized-settings diagnosis pins the culprit exactly:

Culprit settings: --enable_join_runtime_filters False
Step 1: same randomized settings -> 40/40 failed (reproducible)
Step 2: without randomization    -> 75/75 passed

With enable_join_runtime_filters = 0, SELECT 1 FROM (SELECT toLowCardinality(0) a) a FULL JOIN a b USING (a) JOIN a c ON b.a > c.a SETTINGS join_use_nulls = true returns 1 instead of an empty result (b.a > c.a is 0 > 0, so no row should survive).

This looks like a 26.7-only divergence: #112957 ("Restore index analysis for range predicates in JOIN ON", which introduced this very test) was reverted on master by #113478, but that revert was never backported — 26.7 still carries aab152e5ad0e while master does not. So 26.7 runs the reverted code path, and the test only reddens there. CIDB confirms the only 26.7 occurrence in 30 days is this run; the earlier ones were on #112957 itself.

@groeneai, could you investigate and provide a fix in a separate PR (most likely a backport of the #113478 revert to 26.7)? If something is already in progress, please link it here.

I merged 26.7 into this branch for a fresh CI run; the backport diff is unchanged (3 files).

@groeneai

Copy link
Copy Markdown
Collaborator

Investigated. The wrong result is real, but the mechanism differs from the one above, so the suggested fix would be a no-op. Correcting that first, then the actual fix path.

#112957 is not on 26.7. The compare/26.7...aab152e5ad0e "diverged" status cannot discriminate, since a release branch always diverges from a master commit. Reading the tree instead, with aab152e5ad0e itself as a positive control:

ref isUnsafeToEvaluateBelowJoin wouldBecomeJoinKey collectOppositeSideConstants 04695_...sql
aab152e5ad0e (control) 2 3 4 21150 B
master 0 0 0 absent
26.7 0 0 0 absent

The cherry-picks (#113462, #113463) were both closed unmerged, so nothing from #112957 ever reached a release branch. 26.7's JoinStepLogical.cpp numeric-key path is byte-identical to pre-#112957 master. Backporting the #113478 revert to 26.7 would therefore change nothing.

Actual cause: my own #113230 is missing from every release branch. The failing query is the first one in the test (toUInt128), not the b.a > c.a one, which points at key width rather than at JOIN ON analysis. HashJoin::chooseMethod sends a single LowCardinality numeric key wider than 8 bytes to the packed keys128/keys256 map, which reads the dictionary indices as key bytes, so rows match by dictionary position instead of by value. #113230 fixed it in 2 lines (key_sizes[0] = size_of_field;, master HashJoin.cpp:358-359) and merged on 2026-08-04, but it carries no backport label.

Measured on the official per-branch builds, LowCardinality(UInt128) keys 7 vs 9, which must not match:

branch default settings enable_join_runtime_filters=0 04745 (#113230's own test)
master 0 correct 0 correct PASS
26.7 0 1 wrong FAIL (19 lines)
26.6 0 1 wrong FAIL (19 lines)
26.5 0 1 wrong FAIL
26.3 0 1 wrong FAIL
25.8 1 wrong n/a (no such setting) FAIL (31 lines)

Controls: non-LC UInt128 and LowCardinality(UInt64) are correct everywhere, and equal values at different dictionary positions still match, so it is width-gated and LC-specific, as the mechanism predicts. enable_join_runtime_filters=0 is only what exposes it: with filters on the row is discarded before the join, so the same bad match is masked rather than absent. That is why CI pinned that setting. On 25.8 no setting is needed at all, plain Memory tables at defaults return the wrong row.

The randomized-settings diagnosis was right that the setting is the trigger; it just is not the cause, and the failure is not 26.7-only.

Fix path. Rather than a new PR, the clean fix is a label on the existing one: could you apply v25.8-must-backport to #113230? Per tests/ci/cherry_pick_branches.py that floor expands to ['26.7', '26.6', '26.5', '26.3', '25.8'], exactly the affected set. The 2-line hunk applies cleanly to all five (git apply --check rc=0 on each), and key_sizes.resize(keys_size) already precedes the numeric branch on every one, so the write is in range everywhere. I have not hand-authored release-branch PRs, per @ pufit's rule and your own note on #111910.

None of this is related to your backport, so #114564 needs nothing from it. Happy to drive the resulting robot PRs once the label is on.

@clickhouse-gh
clickhouse-gh Bot merged commit 6daacb5 into 26.7 Aug 14, 2026
76 of 79 checks passed
@clickhouse-gh
clickhouse-gh Bot deleted the backport/26.7/112921 branch August 14, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants