Skip to content

Cherry pick #106796 to 26.5: Revert "Revert "Fix LOGICAL_ERROR for reused materialized CTE filtered by IN over another materialized CTE"" - #106861

Merged
robot-ch-test-poll1 merged 4 commits into
backport/26.5/106796from
cherrypick/26.5/106796
Jun 9, 2026
Merged

robot-ch-test-poll1 merged 4 commits into
backport/26.5/106796from
cherrypick/26.5/106796

Conversation

@robot-ch-test-poll1

Copy link
Copy Markdown
Contributor

Original pull-request #106796

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

alexey-milovidov and others added 4 commits June 8, 2026 19:33
The test `04295_04278_materialized_cte_in_union_runtime_set` failed
reproducibly (3/3 reruns) only in the
`Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel)`
configuration, with:

  Code: 60. UNKNOWN_TABLE: Unknown table expression identifier
  '_materialized_cte_ct_<hash>' in scope
  SELECT __table2.b AS b FROM _materialized_cte_ct_<hash> ...
  : While executing Remote.

A materialized CTE's temporary `StorageMemory` is created only on the
initiator. With parallel replicas enabled, the `IN (... UNION ALL ...)`
runtime-set subquery that references the CTE is shipped to the replicas
as part of the remote query. The replicas re-analyze it but have no such
temporary table registered, so resolution fails in `QueryAnalyzer`
during `initializeQueryJoinTreeNode`.

This is a pre-existing limitation of materialized CTEs under parallel
replicas (the storage is not sent to replicas for non-GLOBAL runtime
sets), independent of the planner fix this test guards. Exclude the test
from parallel-replicas runs.

CI history (failures only in the ParallelReplicas config):
https://play.clickhouse.com/play?user=play#V0lUSAogICAgOTAgQVMgaW50ZXJ2YWxfZGF5cwpTRUxFQ1QKICAgIHRvU3RhcnRPZkRheShjaGVja19zdGFydF90aW1lKSBBUyBkYXksCiAgICBjb3VudCgpIEFTIGZhaWx1cmVzLAogICAgZ3JvdXBVbmlxQXJyYXkocHVsbF9yZXF1ZXN0X251bWJlcikgQVMgcHJzCkZST00gY2hlY2tzCldIRVJFIHRlc3RfbmFtZSA9ICcwNDI5NV8wNDI3OF9tYXRlcmlhbGl6ZWRfY3RlX2luX3VuaW9uX3J1bnRpbWVfc2V0JwogICAgQU5EIHRlc3Rfc3RhdHVzIElOICgnRkFJTCcsICdFUlJPUicpCkdST1VQIEJZIGRheQpPUkRFUiBCWSBkYXkgREVTQwo=

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…1-fix-mat-cte

Revert "Revert "Fix LOGICAL_ERROR for reused materialized CTE filtered by IN over another materialized CTE""
@robot-ch-test-poll1 robot-ch-test-poll1 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request labels Jun 9, 2026
@robot-ch-test-poll1
robot-ch-test-poll1 merged commit 55b5ea7 into backport/26.5/106796 Jun 9, 2026
@robot-ch-test-poll1
robot-ch-test-poll1 deleted the cherrypick/26.5/106796 branch June 9, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants