Fix exception in MergingAggregatedTransform with ARRAY JOIN on merge() over Distributed tables#97838
Merged
alexey-milovidov merged 2 commits intoClickHouse:masterfrom Mar 1, 2026
Conversation
…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>
Contributor
alexey-milovidov
approved these changes
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #97564
StorageMerge::getQueryProcessingStagechecked forJOINto returnFetchColumnsstage, but did not check forARRAY JOIN. WhenARRAY JOINwas used withmerge()over multiple Distributed tables, the function returnedWithMergeableState, which causedbuildJoinTreeQueryPlanto early-return and skip theARRAY JOINprocessing entirely. The outer Planner then addedMergingAggregatedStepexpecting pre-aggregated chunks, but received raw chunks withoutAggregatedChunkInfo, leading to aLOGICAL_ERRORexception:The fix adds a
hasArrayJoincheck alongside the existinghasJoincheck so that queries withARRAY JOINalso returnFetchColumnsstage.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
LOGICAL_ERRORexceptionChunk info was not set for chunk in MergingAggregatedTransformwhen usingARRAY JOINwithmerge()table function over multiple Distributed tables combined withGROUP BY.Documentation entry for user-facing changes