Skip to content

Fix runtime join filter producing wrong results for JSON columns - #107663

Merged
Avogar merged 2 commits into
masterfrom
fix-runtime-filter-json-field-roundtrip
Jun 25, 2026
Merged

Avogar merged 2 commits into
masterfrom
fix-runtime-filter-json-field-roundtrip

Conversation

@Avogar

@Avogar Avogar commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

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

Fix runtime join filter producing wrong results for JSON columns. Closes #107646

Version info

  • Merged into: 26.7.1.79 (included in 26.7 and later)
  • Backported to: 26.6.2.18, 26.4.5.94, 26.3.32.7

The `ValuesCount::ONE` optimization in `RuntimeFilterBase` extracted a
`Field` from the Set element column and reconstructed a `ColumnConst`
via `DataType::createColumnConst`. This round-trip was lossy for JSON
columns: `ColumnDynamic::get` returned e.g. `Field(Int64(1))`, but
`FieldToDataType` narrowed it to `Int8` when inserting back into a
fresh `ColumnDynamic`. `ColumnDynamic::compareAt` then saw different
variant type names (`Int64` vs `Int8`) and returned "not equal",
causing the join to incorrectly filter out matching rows.

Fix: store the column from `Set::getSetElements` directly and wrap it
in `ColumnConst` instead of going through the `Field` intermediary.
This preserves the original column representation exactly.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8dfe402]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_tsan, s3 storage, parallel, 2/2) FAIL
03274_squashing_transform_sparse_bug FAIL cidb IGNORED
03568_udf_memory_tracking FAIL cidb IGNORED
Stress test (amd_msan) FAIL
Hung check failed, possible deadlock found FAIL cidb, issue ISSUE EXISTS
Stress test (arm_tsan) FAIL
Hung check failed, possible deadlock found FAIL cidb, issue ISSUE EXISTS

AI Review

Summary

This PR fixes the ValuesCount::ONE runtime join filter path for JSON keys by preserving the original set element column instead of rebuilding a constant through a lossy Field round-trip. The current code and added regression coverage address the prior Tuple(JSON) review concern; I found no remaining code-level blockers or majors.

PR Metadata

The changelog category should be Bug Fix (user-visible misbehavior in an official stable release) rather than Critical Bug Fix (crash, data loss, RBAC), because this is a wrong-result fix but not a release-build exception, data loss, or RBAC issue.

Suggested replacement changelog entry:

Fixed runtime join filters producing wrong results for `JSON` join keys with a single distinct build-side value.

Also move the issue link out of the changelog entry and put it on its own relationship line:

Closes: https://github.com/ClickHouse/ClickHouse/issues/107646
Missing context / blind spots
  • ⚠️ I could not run the new stateless test locally because this checkout has no clickhouse binary, and the direct Praktika report for 8dfe4029377f2e8c10c72ba6e687a45c54b557be currently contains zero test results. A completed stateless run would close this execution gap.
Final Verdict

Status: ✅ Approve

Minimum required actions: none for the code. The PR metadata cleanup above is recommended before merge.

@clickhouse-gh clickhouse-gh Bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Jun 16, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.20% 85.20% +0.00%
Functions 92.30% 92.30% +0.00%
Branches 77.50% 77.40% -0.10%

Changed lines: Changed C/C++ lines covered by tests: 6/6 (100.00%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 1 line(s) · Uncovered code

Full report · Diff report

@m-selmi m-selmi self-assigned this Jun 22, 2026
@Avogar
Avogar added this pull request to the merge queue Jun 25, 2026
Merged via the queue into master with commit b3ff923 Jun 25, 2026
161 of 165 checks passed
@Avogar
Avogar deleted the fix-runtime-filter-json-field-roundtrip branch June 25, 2026 18:04
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jun 25, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 25, 2026
robot-ch-test-poll2 added a commit that referenced this pull request Jun 25, 2026
Cherry pick #107663 to 26.6: Fix runtime join filter producing wrong results for JSON columns
robot-clickhouse added a commit that referenced this pull request Jun 25, 2026
Avogar added a commit that referenced this pull request Jul 1, 2026
Backport #107663 to 26.6: Fix runtime join filter producing wrong results for JSON columns
robot-clickhouse-ci-2 added a commit that referenced this pull request Jul 1, 2026
Cherry pick #107663 to 26.3: Fix runtime join filter producing wrong results for JSON columns
robot-clickhouse added a commit that referenced this pull request Jul 1, 2026
robot-clickhouse-ci-2 added a commit that referenced this pull request Jul 1, 2026
Cherry pick #107663 to 26.4: Fix runtime join filter producing wrong results for JSON columns
robot-clickhouse added a commit that referenced this pull request Jul 1, 2026
robot-clickhouse-ci-2 added a commit that referenced this pull request Jul 1, 2026
Cherry pick #107663 to 26.5: Fix runtime join filter producing wrong results for JSON columns
robot-clickhouse added a commit that referenced this pull request Jul 1, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jul 1, 2026
Avogar added a commit that referenced this pull request Jul 2, 2026
Backport #107663 to 26.5: Fix runtime join filter producing wrong results for JSON columns
Avogar added a commit that referenced this pull request Jul 2, 2026
Backport #107663 to 26.4: Fix runtime join filter producing wrong results for JSON columns
alexey-milovidov added a commit that referenced this pull request Sep 5, 2026
Backport #107663 to 26.3: Fix runtime join filter producing wrong results for JSON columns
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…er-json-field-roundtrip

Fix runtime join filter producing wrong results for JSON columns
bytehalo-infra added a commit to sentioxyz/ClickHouse that referenced this pull request Sep 25, 2026
NULL/RF: a runtime join filter on JSON columns compares the wrong representation and drops matching rows.
Effect in the production build a394e92: wrong (the upstream test fails on it and passes on
official 26.8.8.8; evidence/fix_ci_20260925/upstream_repro). Upstream patch unchanged, with its test(s): 04327_join_runtime_filter_json

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bytehalo-infra added a commit to sentioxyz/ClickHouse that referenced this pull request Sep 25, 2026
…fixes

05059_formatDateTime_extralong_timezone (ClickHouse#117925) and 04327_join_runtime_filter_json
(ClickHouse#107663) join the stateless selection (97 tests); known_defects.json gets their
entries (40, 0 open).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bytehalo-infra added a commit to sentioxyz/ClickHouse that referenced this pull request Sep 25, 2026
JSON: ColumnObject iterated its typed/dynamic path columns in hash-map order -> JSON join keys with several paths miss in the exact-values runtime filter.
Effect in the production build a394e92: without it the 04327_join_runtime_filter_json case with two JSON paths still returns 0 after the ClickHouse#107663 backport (a33ab46) on the candidate 91efe1f244ce, deterministically and with join_runtime_filter_exact_values_limit = 0 as the only workaround; official 26.8.8.8 returns 1. The 26.3 branch merged this backport (ClickHouse#114224, 2026-08-12) before the ClickHouse#107663 backport (ClickHouse#109074, 2026-09-05), so the upstream test passed there.
Upstream patch unchanged, with its test(s): -.
No test of its own; 04327_join_runtime_filter_json (from the ClickHouse#107663 backport) is the regression test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

5 participants