Skip to content

Fix exception in MergingAggregatedTransform with ARRAY JOIN on merge() over Distributed tables#97838

Merged
alexey-milovidov merged 2 commits intoClickHouse:masterfrom
Algunenano:fix-merge-distributed-array-join
Mar 1, 2026
Merged

Fix exception in MergingAggregatedTransform with ARRAY JOIN on merge() over Distributed tables#97838
alexey-milovidov merged 2 commits intoClickHouse:masterfrom
Algunenano:fix-merge-distributed-array-join

Conversation

@Algunenano
Copy link
Copy Markdown
Member

Closes #97564

StorageMerge::getQueryProcessingStage checked for JOIN to return FetchColumns stage, but did not check for ARRAY JOIN. When ARRAY JOIN was used with merge() over multiple Distributed tables, the function returned WithMergeableState, which caused buildJoinTreeQueryPlan to early-return and skip the ARRAY JOIN processing entirely. The outer Planner then added MergingAggregatedStep expecting pre-aggregated chunks, but received raw chunks without AggregatedChunkInfo, leading to a LOGICAL_ERROR exception:

Chunk info was not set for chunk in MergingAggregatedTransform

The fix adds a hasArrayJoin check alongside the existing hasJoin check so that queries with ARRAY JOIN also return FetchColumns stage.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fix LOGICAL_ERROR exception Chunk info was not set for chunk in MergingAggregatedTransform when using ARRAY JOIN with merge() table function over multiple Distributed tables combined with GROUP BY.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

…erge()` over Distributed tables

`StorageMerge::getQueryProcessingStage` checked for `JOIN` to return
`FetchColumns` stage, but did not check for `ARRAY JOIN`. When `ARRAY JOIN`
was used with `merge()` over multiple Distributed tables, the function
returned `WithMergeableState`, which caused `buildJoinTreeQueryPlan` to
early-return and skip the `ARRAY JOIN` processing entirely. The outer
Planner then added `MergingAggregatedStep` expecting pre-aggregated
chunks, but received raw chunks without `AggregatedChunkInfo`.

The fix adds a `hasArrayJoin` check alongside the existing `hasJoin`
check so that queries with `ARRAY JOIN` also return `FetchColumns` stage.

Fixes ClickHouse#97564

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Feb 24, 2026

Workflow [PR], commit [943e02e]

Summary:

@clickhouse-gh clickhouse-gh bot added the pr-bugfix Pull request with bugfix, not backported by default label Feb 24, 2026
@alexey-milovidov alexey-milovidov self-assigned this Mar 1, 2026
@alexey-milovidov alexey-milovidov added this pull request to the merge queue Mar 1, 2026
Merged via the queue into ClickHouse:master with commit bd13234 Mar 1, 2026
148 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 1, 2026
alexey-milovidov added a commit that referenced this pull request Mar 1, 2026
…-join

Fix exception in MergingAggregatedTransform with ARRAY JOIN on merge() over Distributed tables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default 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.

Logical error: Chunk info was not set for chunk in MergingAggregatedTransform. (STID: 3800-3cec)

3 participants