Skip to content

Use castStorage for the Join row policy check in the legacy analyzer - #124441

Merged
vdimir merged 1 commit into
masterfrom
vdimir/legacy-join-row-policy-cast-storage
Oct 8, 2026
Merged

vdimir merged 1 commit into
masterfrom
vdimir/legacy-join-row-policy-cast-storage

Conversation

@vdimir

@vdimir vdimir commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #121398. That PR was also not fully backported, so the missing changes will be included in the backports of the current PR.

typeid_cast compares the exact dynamic type, so the row policy check for Join tables in the legacy analyzer (JoinedTables::makeTableJoin) matched StorageJoin itself and nothing derived from it. castStorage is a dynamic_pointer_cast that also looks through StorageTableProxy, and it is how the new analyzer, joinGet, and the setStorageJoin branch a few lines below already detect a Join table.

On master the legacy analyzer is not reachable from user queries, so this changes nothing observable here. It matters for the release branches that still run the legacy analyzer, where the backport of #121398 otherwise joins a storage derived from StorageJoin under a row policy as a filtered stream instead of failing with ACCESS_DENIED.

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.10.1.1804-master (included in 26.10 and later)
  • Backported to: 26.9.15.5, 26.8.23.6, 26.7.26.9, 26.3.51.8

`typeid_cast` compares the exact dynamic type, so the check added in
#121398 matched `StorageJoin`
itself and nothing derived from it. `castStorage` is a `dynamic_pointer_cast`
that also looks through `StorageTableProxy`, and it is how the new analyzer,
`joinGet`, and the `setStorageJoin` branch a few lines below already detect
a `Join` table.

On master the legacy analyzer is not reachable from user queries
(`enable_analyzer = 0` is replaced with `1`), so this changes nothing
observable here. It matters for the release branches that still run the
legacy analyzer, where the backport of the same check otherwise joins a
storage derived from `StorageJoin` under a row policy as a filtered stream
instead of failing with `ACCESS_DENIED` like a `Join` table does.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@vdimir vdimir added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Oct 7, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d59ee36]

Summary: ✅


AI Review

Summary

This PR tightens the legacy-analyzer row-policy guard in src/Interpreters/JoinedTables.cpp:290 by switching it to the same proxy-aware castStorage path already used a few lines later to install StorageJoin on TableJoin. I did not find a correctness or safety issue in the current diff: the change is narrowly scoped, preserves the existing ACCESS_DENIED behavior, and removes the mismatch where the guard and the direct-join detection used different storage-type tests.

Missing context / blind spots
  • ⚠️ The legacy-analyzer path this targets is not user-reachable on current master, so the release-branch effect cannot be exercised in this checkout. The green CI run and the helper semantics make the change look mechanically correct, but end-to-end confirmation still happens only once the cherry-pick lands on a branch that still supports enable_analyzer = 0.
Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit d59ee36.

Metric Baseline Current Δ
Lines 88.30% 88.30% +0.00%
Functions 92.10% 92.10% +0.00%
Branches 79.80% 79.70% -0.10%

Changed lines: Changed C/C++ lines covered: 2/6 (33.33%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog comp-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... labels Oct 7, 2026
@vdimir
vdimir added this pull request to the merge queue Oct 8, 2026
Merged via the queue into master with commit e9fd1ee Oct 8, 2026
152 checks passed
@vdimir
vdimir deleted the vdimir/legacy-join-row-policy-cast-storage branch October 8, 2026 08:44
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 8, 2026
@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 8, 2026
robot-ch-test-poll added a commit that referenced this pull request Oct 9, 2026
Cherry pick #124441 to 26.3: Use `castStorage` for the `Join` row policy check in the legacy analyzer
robot-clickhouse added a commit that referenced this pull request Oct 9, 2026
robot-ch-test-poll added a commit that referenced this pull request Oct 9, 2026
Cherry pick #124441 to 26.7: Use `castStorage` for the `Join` row policy check in the legacy analyzer
robot-clickhouse added a commit that referenced this pull request Oct 9, 2026
robot-ch-test-poll added a commit that referenced this pull request Oct 9, 2026
Cherry pick #124441 to 26.8: Use `castStorage` for the `Join` row policy check in the legacy analyzer
robot-clickhouse added a commit that referenced this pull request Oct 9, 2026
robot-ch-test-poll added a commit that referenced this pull request Oct 9, 2026
Cherry pick #124441 to 26.9: Use `castStorage` for the `Join` row policy check in the legacy analyzer
robot-clickhouse added a commit that referenced this pull request Oct 9, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 9, 2026
vdimir added a commit that referenced this pull request Oct 10, 2026
The resolved cherry-pick kept both sides of the conflict: the `Join` table check from
#124441 and the trimmed guard backported earlier from
#121398, with the old comment split between them.
Keep the check only and declare `ErrorCodes::ACCESS_DENIED`, which the file never had.

`castStorage` comes to 26.3 with #124513, which has
to be merged first; include `Storages/StorageProxy.h` for it as the other branches do.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
vdimir added a commit that referenced this pull request Oct 10, 2026
The resolved cherry-pick kept both sides of the conflict: the `Join` table check from
#124441 and the trimmed guard backported earlier from
#121398, with the old comment split between them.
Keep the check only and declare `ErrorCodes::ACCESS_DENIED`, which the file never had.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
vdimir added a commit that referenced this pull request Oct 10, 2026
The resolved cherry-pick kept both sides of the conflict: the `Join` table check from
#124441 and the trimmed guard backported earlier from
#121398, with the old comment split between them.
Keep the check only and declare `ErrorCodes::ACCESS_DENIED`, which the file never had.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
vdimir added a commit that referenced this pull request Oct 10, 2026
The resolved cherry-pick of #124441 uses
`ErrorCodes::ACCESS_DENIED`, `RowPolicyFilterType` and `RowPolicyFilter::isAlwaysTrue`, but the
file neither declares the error code nor includes the row policy headers: `Context.h` only
forward-declares those types.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
vdimir added a commit that referenced this pull request Oct 10, 2026
The earlier backport of #121398 to this branch was
reverted. Add it back on top of #124441: `joinGet`
and `joinGetOrNull` fail with `ACCESS_DENIED` while a row policy applies to the `Join` table,
the analyzer does the same in `buildQueryPlanForJoinNode` instead of joining the table as a
stream, the documentation says so, and tests 05233 and 05234 cover it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
clickhouse-gh Bot added a commit that referenced this pull request Oct 10, 2026
Backport #124441 to 26.8: Use `castStorage` for the `Join` row policy check in the legacy analyzer
clickhouse-gh Bot added a commit that referenced this pull request Oct 10, 2026
Backport #124441 to 26.9: Use `castStorage` for the `Join` row policy check in the legacy analyzer
clickhouse-gh Bot added a commit that referenced this pull request Oct 10, 2026
Backport #124441 to 26.7: Use `castStorage` for the `Join` row policy check in the legacy analyzer
vdimir added a commit that referenced this pull request Oct 14, 2026
Backport #124441 to 26.3: Use `castStorage` for the `Join` row policy check in the legacy analyzer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-joins JOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore 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-not-for-changelog This PR should not be mentioned in the changelog 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