Repository navigation
Conversation
flattenArrayTableExpressionOnRightOfIn (added for x IN some_array_table) rewrote any single-Array-column TableNode into a SELECT column FROM table subquery. A Set-engine table matches that shape but has no read method and is consumed natively as a prepared set, so the rewrite made the planner call IStorage::read on it: scalar IN a Set of Array now threw NOT_IMPLEMENTED: Method read is not supported by storage Set. Skip the flatten for StorageSet, restoring the native prepared-set path (the elements of a Set of Array are whole array rows: an array left argument matches a row, a scalar left argument is a type mismatch, exactly as before the array-table flattening was added). The commit that introduced the helper already stated the StorageSet fast path must be unchanged; the guard was missing. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260715-072400 |
|
cc @novikd @vdimir - review please. flattenArrayTableExpressionOnRightOfIn (f322da8) rewrote a single-Array-column StorageSet into a SELECT-from-table subquery, but StorageSet has no read and is a native prepared set, so scalar IN over it threw NOT_IMPLEMENTED. This skips the flatten for StorageSet. |
|
Workflow [PR], commit [17e0616] Summary: ❌
AI ReviewSummaryThis PR fixes Missing context / blind spots
Findings❌ Blockers
Final Verdict❌ Needs changes. I would merge the OSS |
Switch the guard from typeid_cast (exact type) to dynamic_cast<const StorageSet *> so the Cloud-only StorageSharedSet, which derives from StorageSet, is also skipped by the array-table flatten and keeps the native prepared-set path. The rest of the IN pipeline already treats derived set storages as the same family via dynamic_cast (CollectSets, ActionsVisitor), so the exact-type check was inconsistent. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Good catch, done in d9b5d91. Switched the guard to
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260715-095000 |
A StorageSet reached through ENGINE=Alias('set_table') was not recognized as a
set-backed table on the right of IN. The analyzer guard and the planner both used
an exact/dynamic_cast check on the immediate storage, so the alias wrapper (whose
read delegates to the target) was flattened into a SELECT column FROM table
subquery, and the fallback plan then read through the alias into StorageSet::read,
reproducing NOT_IMPLEMENTED: Method read is not supported by storage Set.
Add a shared getSetStorageFromTable helper that unwraps a StorageAlias chain to
its target and matches StorageSet (including derived set storages), and use it in
both resolveFunction (analyzer) and CollectSets (planner), so a set-backed table
is consumed natively as a prepared set through any alias wrapping.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Confirmed and fixed in d1671b9. Reproduced on the prior build: Added a shared helper Note: alias-to-alias chains are rejected at CREATE time (BAD_ARGUMENTS), so the depth-bounded walk is defensive only. |
CI finish ledger — d1671b9All failures on this commit are the single ongoing infra runner outage; none are caused by this PR's diff. Every failure has an owner.
Session id: cron:our-pr-ci-monitor:20260715-153000 |
… paths The shared getSetStorageFromTable helper resolves a set-backed table through StorageAlias wrappers, and the analyzer and the planner already use it. Two other consumers still tested the immediate storage, so `x IN alias_to_set` remained broken in both of them: - src/Interpreters/ActionsVisitor.cpp: the legacy IN implementation resolved the table itself and only checked `dynamic_cast<StorageSet *>` / `dynamic_cast<StorageSharedSet *>` on it, so with `enable_analyzer = 0` the alias fell through to the ordinary table-read path and threw `NOT_IMPLEMENTED: Method read is not supported by storage Set`. - src/Processors/QueryPlan/SetsSerialization.cpp: makeSetsFromStorage rebuilds a storage-backed set from its table name after a plan is deserialized, using `typeid_cast<const StorageSet *>`. On the serialized-plan path (distributed-plan execution) the alias therefore threw `INCORRECT_DATA: Table ... is not a StorageSet` instead of reusing the prepared set. Both now go through the helper, so a set-backed table is never read on the right of IN regardless of the analyzer setting or of whether the plan was serialized. The Cloud SharedSet branch in ActionsVisitor keeps its behavior: the helper matches derived set storages too, and the name check selects the context-aware getSet overload, mirroring what Planner/CollectSets already does. Both sites were confirmed on the previous PR head (prebuilt amd_debug 4e57ec6, build id ebfd7955) with the exact errors above, and both are fixed by this commit (build id 71e0e9b8). Reverting either hunk alone reddens only its own regression, so each is load-bearing and they are independent. Regressions: the legacy-analyzer spelling extends 04512, and the serialized-plan spelling is a new two-shard test 04652.
CI finish ledger - 4e57ec6Every failure below has an owner: a fixing PR, or a full-effort fix task whose
Session id: cron:our-pr-ci-monitor:20260729-083000 |
getSetStorageFromTable returned a raw StorageSet *. For a direct StorageSet that is fine, because the caller already holds the StoragePtr it passed in. Through a StorageAlias it is not: the target comes from alias->tryGetTargetTable(), which returns a fresh shared_ptr, and the only owner was the helper's own local. Context::getOrCacheStorage caches StorageID values, not StoragePtr, so nothing on the caller side kept the target alive; its lifetime rested on the database's tables map instead of on the caller. Return std::shared_ptr<StorageSet> so the caller shares ownership of whatever it is about to call getSet on, and update the four call sites. The two Cloud SharedSet branches take .get() for their static_cast, which keeps their behavior unchanged. Found by the second-model review of the previous commit.
…h an Alias
Reading a table through an Alias checks SELECT on the target: StorageAlias::read
resolves it with getTargetTable(TargetAccess{context, AccessType::SELECT, ...}).
Consuming a set-backed target as a prepared set on the right of IN replaces that
read, so it has to require the same grant.
Recognizing the set-backed table through the alias made three prepare paths
resolve the target with the unchecked tryGetTargetTable and consume it without
entering StorageAlias::read, so a user granted SELECT on the alias only could
read the target set. On pristine master the analyzer spelling was ACCESS_DENIED,
so the check had to be restored, not introduced.
getSetStorageFromTable now takes an optional context and, when given one,
resolves an alias with the same SELECT check that reading it performs. The three
consuming callers (the planner, the legacy IN implementation and the
serialized-plan reconstruction) pass the query context. The analyzer call site
only asks whether the table is set-backed before deciding not to rewrite it into
a subquery, and does not consume it, so it passes no context and stays a pure
recognizer.
Reading a set-backed table directly through IN has never checked SELECT on it,
on master or before this change. That is a pre-existing, engine-wide question
about the direct spelling and is left alone here.
vdimir
left a comment
There was a problem hiding this comment.
Why marked as 'Not for changelog'?
Reading through an alias requires SELECT on the alias and on the target: the planner checks the alias in checkAccessRights and StorageAlias::read checks the target. Consuming a set-backed target as a prepared set replaces both, so it has to require both. Only the target check was there, so a user granted SELECT on the target but not on the alias could use the alias, where an ordinary alias on the right of IN is denied. Measured against an equivalent MergeTree alias on the right of IN, across all four grant combinations, both analyzer settings and the serialized plan. The two now agree everywhere: alias only denied, target only denied, alias plus a column-level target grant denied (a table-wide target grant is what both need), both granted allowed. The regression covers the target-only case and adds a cluster query with serialize_query_plan = 1 for the deserialization path. Note the serialized case is currently decided on the initiator, before the plan is sent: removing the context from the planner call makes those rows pass, while removing it from SetsSerialization alone does not, so the check there is defence in depth rather than the deciding one.
… column The helper is called for the table on the right of every IN, before anything knows whether its target is set-backed, so checking while walking the alias chain applied set semantics to aliases that resolve to something else. A user holding column-level SELECT on an Alias to a Memory table could use it on the right of IN and then could not, which the change had no business affecting. The walk now resolves first and checks only once a StorageSet is found, so an alias to anything else is left exactly as it was. The check is also column-scoped over the target's columns instead of table-wide: the whole set is consumed, and that is what an ordinary alias on the right of IN accepts, so a column-level grant covering every column is now enough here too, and one that misses a column is not. Compared against an equivalent MergeTree alias on the right of IN across five grant combinations, both analyzer settings and the serialized plan, the two agree in every cell: alias only denied, target only denied, alias plus a partial column grant denied, alias plus a grant on all columns allowed, both table-wide allowed. A set-backed table named directly still needs no grant, as before.
…cidable The walk collected raw StorageAlias pointers and then advanced the only owning StoragePtr to the next target, so nothing kept an intermediate alias of a chain alive until the access check ran over it. Chains are reachable: an alias may be created while its target does not exist yet, and that target may then be created as another alias. Only the ids are needed, so the walk now stores those and holds no pointer past the iteration that produced it. The regression used a single-column Set, where a grant on one column and a grant on every column are the same thing, so it could not tell the intended check from one that looks at one column only. The set is now two columns and the test distinguishes both directions, on the target and on the alias: a grant covering every column is accepted, a grant missing one is denied. Checking only the first column, or table-wide instead of by column, each makes it fail.
…cumentation Wrap the class, function and SQL names in the comments this branch adds in inline code blocks, as the repository asks for. Only lines added here are touched. The helper documentation still said resolving through an alias requires `SELECT` on the target, which stopped being the whole story once the alias itself is checked too.
The plan is only serialized on the analyzer's remote path, and the runner randomizes both `enable_analyzer` and `prefer_localhost_replica`, so `04652` could draw a local or query-text plan and pass without ever rebuilding a set on a receiving side. Both are now pinned, as they already were in `04653`. Also say in `04653` what its serialized rows do and do not establish: both ends check and the initiator checks first, so those rows assert the outcome, not which end produced it. Giving the two ends different grants needs more than one node.
The three comment blocks this branch added restated the motivation that belongs in the commit messages. Keep the part a reader needs at the call site: what the helper returns and owns, which grants a consuming caller needs, and that a set-backed table must not be rewritten into a subquery.
|
Fixing PR for the Root cause: #109339 added a Timeline: #109339 merged 2026-07-28 13:16 UTC, the master cascade began the same evening, #112381 reverted it 2026-07-29 01:39 UTC. Every failing build contained the introducing commit and lacked the revert. True-master runs since the revert are clean: 0 failures against 6804 passing rows across 23 distinct commits. #112382 re-lands the feature with No action is needed on this PR: its diff never touched PostgreSQL replication and did not cause this line. |
|
You are right, and my "not for changelog" was based on a wrong premise. I have changed the category to I had described this as unreleased-master-only, but the commit that introduced the rewrite (f322da8) is an ancestor of
So there are two released-version bugs here, not one: the array-table rewrite added the direct-spelling failure in 26.7, and the alias spelling has been failing since at least 26.5 because the three "is this set-backed" checks only ever looked at the immediate storage. One thing I cannot do myself: the I have not pushed anything, so your approval is untouched. Head is still 1338e9c. |
CI finish ledger - 1338e9cEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only
174 check-runs on this head, all completed: 1 failure, the row above. The two Session id: cron:our-pr-ci-monitor:20260729-193000 |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 38/41 (92.68%) · Uncovered code |
CI finish ledger - 17e0616Every failure below has an owner: a fixing PR (ours or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260801-230000 |
|
Fixing PR for the pre-auth That PR reapplies #110760 (reverted in #112935) together with the fix: |
|
Fixing PR for the STID 3358-2d6d It stops BuzzHouse from randomly arming |
BuzzHouse enables a random failpoint from \`system.fail_points\`. Two of them - \`attach_to_group_failure\` and \`thread_group_switcher_post_attach_failure\` - deliberately break the invariant that a query thread is attached to a thread group. \`ThreadGroupSwitcher\` is \`noexcept\` and only logs the injected failure, so the thread carries on with no group and the next \`executeQuery\` that runs on it fails with the \`No thread group attached to the thread\` logical error, e.g. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112766&sha=25a457c530e81c122d764503aa913d2d04eedbb1&name_0=PR&name_1=BuzzHouse%20%28amd_msan%29 (ClickHouse#112766). The same failure hit ClickHouse#110514 in \`BuzzHouse (amd_debug)\` on the same day. Both failpoints exist for the in-process unit test \`gtest_thread_group_switcher\`, which enables them around a single controlled switch; they are not meaningful to inject from SQL. Exclude them from the list the fuzzer picks from, like the other failpoints that legitimately take the server down.
|
Dear @vdimir, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
Code: 48. NOT_IMPLEMENTED: Method read is not supported by storage Setwhen aSet-engine table, or aAliastable pointing at one, is used on the right side ofIN. Such tables are now always consumed as a prepared set instead of being read, in the analyzer, the legacyINimplementation, and the serialized-plan path. Closes #110505.Description
Closes: #110505
A single-
Array-column table on the right ofINis rewritten into aSELECT column FROM tablesubquery so its elements become the set elements. ASet-engine table matches that shape but has noreadmethod: it is meant to be consumed natively as a prepared set. So the rewrite madeINover set-backed tables fail withCode: 48. NOT_IMPLEMENTED: Method read is not supported by storage Set.The three places that decide "is this a set-backed table" each looked only at the immediate storage, so a
Aliaswrapper (whosereaddelegates to its target) was never recognized. This adds a shared helper,getSetStorageFromTable, that resolves through an alias chain and matchesStorageSetincluding derived types, and routes all three call sites through it: the analyzer (Analyzer/Resolve/resolveFunction.cpp,Planner/CollectSets.cpp), the legacy implementation (Interpreters/ActionsVisitor.cpp, reached withenable_analyzer = 0), and plan deserialization (Processors/QueryPlan/SetsSerialization.cpp, reached in distributed-plan execution).Reproduces on released versions, so this is not master-only:
ENGINE = Aliasis generally available in all three (allow_experimental_alias_table_engineis obsolete), and the same query over anAliasto a readable table always worked, so the failure was specific to set-backed targets.Access checking is unchanged from before the rewrite: a set-backed alias on the right of
INrequires the same grants as an equivalentAliasto aMergeTreetable, verified across 5 grant combinations in both analyzer modes and on the serialized-plan path.Regressions:
04512_in_function_array_subquery_right_argument(direct, alias, legacy mode, access) and04652_in_set_alias_serialized_query_plan(serialized plan).