Repository navigation
Keep an ARRAY JOIN filter out of a Merge child query - #119307
Conversation
`SELECT count() FROM mrg ARRAY JOIN data WHERE data IN ('aaa')`, where `mrg` is a `Merge` table over a
`Distributed` table, threw ``Column `__array_join_exp_1` not found in table ...``. The same query over
the local table, over the `Distributed` table, or over a `Merge` table whose child is a plain
`MergeTree` returned the rows.
`replaceTableExpressionAndRemoveJoin` builds the child query by replacing the outer query's join tree
with the child table expression, and `cloneAndReplace` rewires every column sourced from the replaced
node onto the replacement. With `ARRAY JOIN` as the join tree, that node is the `ARRAY JOIN` itself, so
its result column ended up claiming to come from the child table: the filter over it then looked like a
filter over the child's own columns and survived the cleanup that follows, and the child was asked to
read `__array_join_exp_1`. Only a `Distributed` child noticed, because it is the one that re-analyzes
the child query.
Drop such a filter before the join tree is replaced, while its columns still point at the `ARRAY JOIN`
node, so that `hasUnknownColumn` recognizes them. `StorageMerge` reads its children with
`FetchColumns` when the query has an `ARRAY JOIN`, so the array join and this filter are performed on
the initiator either way. A filter over the table's own columns is unaffected - the replacement above
has already rewired it onto the child table expression - and a conjunction of both kinds keeps the part
that belongs to the child.
Closes: #115274
|
Workflow [PR], commit [eee90d1] Summary: ✅
AI ReviewSummaryThis PR fixes the analyzer-path bug where Final Verdict
LLVM Coverage ReportMeasured on commit eee90d1.
Changed lines: Changed C/C++ lines covered: 8/10 (80.00%) · Uncovered code |
|
Both red checks are unrelated to this change.
Related: #118722 |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 21 s compile time in total, 7 of them have a recent master baseline. |
|
🕵 @groeneai, investigate the failures and provide a fix in a separate PR. If the fix is already in progress, link it here.
Neither one is related to this PR, which only changes |
|
Both failures are from the 2026-09-24 run (head
The fresh run on |
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=119307&sha=2eee930ba6e9b831a47021daccc00e45007287dd&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20AsyncInsert%2C%20s3%20storage%2C%20parallel%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. The job hit its 9000 s timeout at test 14250 of 15130 with no failed tests; the same |
|
The fix is in progress and it is mine: #116209. It splits this job and its The run on If the PR coverage opt-in (#122853, reverted in #123789) comes back, master still runs this job on every commit, so the split is still needed there; the batched names keep matching its |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix
Column `__array_join_exp_1` not found in tableforARRAY JOINwith a filter on the array-joined column over aMergetable whose child is aDistributedtable.Documentation entry for user-facing changes
...
SELECT count() FROM mrg ARRAY JOIN data WHERE data IN ('aaa'), wheremrgis aMergetable over aDistributedtable, threwColumn `__array_join_exp_1` not found in table .... The same query over the local table, over theDistributedtable, or over aMergetable whose child is a plainMergeTreereturned the rows.replaceTableExpressionAndRemoveJoinbuilds the child query by replacing the outer query's join tree with the child table expression, andcloneAndReplacerewires every column sourced from the replaced node onto the replacement. WithARRAY JOINas the join tree, that node is theARRAY JOINitself, so its result column ended up claiming to come from the child table: the filter over it then looked like a filter over the child's own columns and survived the cleanup that follows, and the child was asked to read__array_join_exp_1. Only aDistributedchild noticed, because it is the one that re-analyzes the child query.Drop such a filter before the join tree is replaced, while its columns still point at the
ARRAY JOINnode, so thathasUnknownColumnrecognizes them.StorageMergereads its children withFetchColumnswhen the query has anARRAY JOIN, so the array join and this filter are performed on the initiator either way. A filter over the table's own columns is unaffected — the replacement above has already rewired it onto the child table expression — and a conjunction of both kinds keeps the part that belongs to the child.New test:
05197_merge_over_distributed_array_join_filter. Verified in both directions, and a differential run of themerge_table/array_join/storage_merge/distributed/viewstateless tests shows no new failures.Closes: #115274
Workflow [PR]
Sync PR [sync-upstream/pr/119307]
Version info
26.10.1.1519-master(included in26.10and later)