Repository navigation
Push subcolumn reads into subqueries - #112688
alexey-milovidov wants to merge 129 commits into
Conversation
New query tree pass PushSubcolumnsIntoSubqueries: when a subcolumn of a column exported by a subquery, CTE or view is requested (resolved into the `getSubcolumn` function over the whole column), add the subcolumn to the subquery projection and replace the function with a reference to it. If the whole column is not used anywhere else, it is then removed from the subquery projection by the RemoveUnusedProjectionColumns pass, and only the subcolumn is read from the table. Controlled by the new setting optimize_push_subcolumns_into_subqueries (enabled by default). Closes #75538 Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [69843c3] Summary: ✅
AI ReviewSummaryThe PR pushes subcolumn reads through subqueries, CTEs and Findings❌ Blockers
Tests
Final Verdict❌ Block. Protect local shard headers and explicit indexed expressions, remove the repeated full-part column scans, and make the provenance regression exercise pushdown. |
…eExpressionNode join tree accessors Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
`QueryTreePassManager::runOnlyResolve` ran a hardcoded number of the first passes (4), which was meant to cover `QueryAnalysisPass`, `GroupingFunctionsResolvePass`, `AutoFinalOnQueryPass` and `RemoveUnusedProjectionColumnsPass`. Inserting `PushSubcolumnsIntoSubqueriesPass` before `RemoveUnusedProjectionColumnsPass` shifted the latter out of that range, so the secondary queries on the shards stopped pruning unused projection columns of `VIEW`s and read all the columns of the underlying table. This broke `03550_analyzer_remote_view_columns`. Look up the index of `RemoveUnusedProjectionColumnsPass` by name instead of hardcoding it, so that adding a pass before it does not silently exclude it.
|
📊 Cloud Performance Report ✅ AI verdict: This PR adds an analyzer pass that pushes subcolumn reads (Map keys/values, Nullable null maps, tuple elements, JSON paths) into subqueries, and moves a helper out of FunctionToSubcolumnsPass. The pass only matches when a column comes from a subquery or UNION. ClickBench Q32 (+14.8%) and Q33 (+8.6%) are plain single-table aggregations with neither, so the pass cannot change their plans or execution. Both stay within master's recent variance range, and the deterministic suppression agrees with the diff. CPU time is higher on both, which fits the source run sharing its host with the TPC-H benchmark rather than a code effect, so no performance change is attributed to this PR. clickbenchFlagged queries (2 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
…subcolumn pushdown - Gate the table branch of `buildSubcolumnProjectionNode` on `supportsOptimizationToSubcolumns` instead of `supportsSubcolumns`, so storages that expose subcolumns syntactically but opt out of rewriting column reads into direct subcolumn reads (`StorageFile`, `StorageURL`, `StorageDistributed`, object storage engines) are not affected. Also skip virtual columns, aligned with `FunctionToSubcolumnsPass`. - Filter `eligible_targets` by each target subquery's own value of `optimize_push_subcolumns_into_subqueries`, so disabling the setting inside a subquery or CTE via a `SETTINGS` clause protects that subquery from being rewritten by its parent, and use the subquery's own context when building deeper `getSubcolumn` nodes. - Add the test `04665_push_subcolumns_into_subqueries_guards` covering both contracts. Co-Authored-By: Claude Fable 5 <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 256/275 (93.09%) · Uncovered code |
…tion Two tests requested in the review: - `04667_push_subcolumns_into_subqueries_view_source` covers a dependent materialized view whose query reads a subcolumn through a subquery and through a CTE. On that path the source table is represented by `StorageValues` holding the inserted block. `StorageValues` reads subcolumns of the block with `getColumnOrSubcolumnByName`, so the pushdown is safe there; the test pins that behavior. - `04668_push_subcolumns_into_subqueries_read_bytes` measures `read_bytes` of the same query with `optimize_push_subcolumns_into_subqueries` off and on: reading `tup.a` of a `Tuple(a UInt32, b String)` through a subquery reads 400 KB instead of 21 MB (53 times less) on 100000 rows.
Build profile diff (arm_release)Comparing Binary sizes
The official master build is compiled with Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/CMakeFiles/dbms.dir/Analyzer/Passes/PushSubcolumnsIntoSubqueriesPass.cpp.o |
new | 587.82 KiB | +587.82 KiB |
src/CMakeFiles/dbms.dir/Analyzer/QueryTreePassManager.cpp.o |
86.53 KiB | 59.40 KiB | -27.12 KiB (-31.35%) |
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Compile time of recompiled translation units
126 translation units recompiled, 831 s compile time in total, 125 of them have a recent master baseline.
Translation units without a recent master baseline:
src/Analyzer/Passes/PushSubcolumnsIntoSubqueriesPass.cpp: 12.4 s
|
🕵 The only failure in the last public CI run, |
|
🕵 Both remaining CI failures on commit 2b4e2e7 are unrelated to this PR (the analyzer pass only rewrites subcolumn reads over subqueries/CTEs; both failures come from fuzzed/stress queries that never touch it, and both signatures occur on master and on dozens of other PRs):
@groeneai, investigate the MSan hung-check flood (item 2): the cancelled |
|
Investigated item 2. An owner exists for the writer path you describe, but the flood you are pointing at is mostly a different mechanism, which I think matters for what to fix. The writer path: #108357 owns it. "Make column data write during INSERT respond to query cancellation" (open, external) adds But this row is not representative of the flood. I pulled
All 20 are a fuzzer-generated One correction to the CPU claim, because it changes which fix helps: this query was not burning CPU for the full 1893 s. Nothing here is attributable to this PR: no I am not opening anything new, since #108357 and #113140 between them own 22 of the 27 rows. Happy to file a tracking issue for the residual 5 if you want one. |
… materialized CTEs Support the subcolumn pushdown for subqueries spelled with an alias list, e.g. `SELECT x.a FROM (SELECT json FROM t) AS s(x)`: the overridden names are already baked into the projection columns after analysis, so the pass only needs to keep `projection_aliases_to_override` in sync when `QueryNode::addProjectionColumn` appends a column. The blanket rejection of such subqueries in `canAddProjectionColumns` is removed, and the new test `04813_push_subcolumns_into_subqueries_alias_list` checks that only the subcolumn is read for several alias-list shapes. Reused `MATERIALIZED` CTEs stay TableNode references over the temporary table that serves all references of the CTE, so pruning the parent column there would require proving that no reference needs the whole column, and adding the subcolumn without removing the parent column would only make the materialized table bigger. Such references are deliberately left as is; this is now documented in `matchCandidate`, and the new test `04814_push_subcolumns_into_subqueries_materialized_cte` checks that subcolumn reads over reused materialized CTEs stay correct with the optimization enabled. Subcolumn reads over materialized CTEs are broken on master in ways independent of this change (any subcolumn of a single-use materialized CTE, `Tuple` subcolumns of reused ones), see issue #113623. Co-Authored-By: Claude Fable 5 <[email protected]>
…mns into subqueries Move the helper `resolveTrivialAliasChain` from `FunctionToSubcolumnsPass` to `Analyzer/Utils` so that `PushSubcolumnsIntoSubqueriesPass` can reuse it: an exported ALIAS column whose body is just another column of the same table (possibly chained) is semantically the underlying storage column, so the subcolumn can be read directly from the table instead of keeping `getSubcolumn` over the whole column above the subquery. Co-Authored-By: Claude Fable 5 <[email protected]>
…lazy `JSON` type hints - A `tupleElement` whose element name is a nested path of another element when flattened (`a.b` next to `a`) is no longer a pushdown candidate. Every form of the pushdown names the element by its flattened name: a direct subcolumn read was already guarded, but the intermediate `getSubcolumn(c, 'a.b')` built for a deeper subquery read `a`.`b` instead of the literal element `a.b` (3 instead of 99 through two subquery layers, also for a positional selector and for function-form exports). - `hiddenFilterReadsContainingColumn` expands `ALIAS` columns of the table (recursively) in a row policy or `additional_table_filters`, as the planner does, so `cityHash64(a1) > 0` with `a1 ALIAS tup` keeps `tup` read and the subcolumn is extracted from it. - A subcolumn of a `JSON` column is not read directly from a `MergeTree` table while some of its parts store the column with another type than the metadata (a lazy type hint change). The reader resolves the subcolumn against the type of the old part and returns defaults (#123339), so the pass newly turned a correct whole-column extraction into `NULL`. The override of the setting in `05301_json_shared_typed_paths_alter` is removed: the test passes with the pushdown enabled. Regressions are in `05456_push_subcolumns_into_subqueries_review_fixes_7`. #112688 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es_union` The depth of the read step under `UNION DISTINCT` in `EXPLAIN` varies between runs (`│ Output: tup` vs `│ Output: tup`), which made the test flaky. Collapse the spaces after the plan tree marker; the order of the `Output` lines still shows the rewrite. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=112688&sha=b46a82a6cdadad921c5c299fb559ed0989403f92&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29 #112688 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s_7` Master added another test with the number `05456`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Addressed the three new review threads (719d242) and merged master. @groeneai, investigate the failure: Stress test (amd_debug), a segmentation fault in |
|
Fixed by #127912, merged yesterday at 15:13 UTC. This run built b46a82a merged into master 079b5ce, which predates the fix; the current run for ffc1256 builds on 6624a33, which contains it, so nothing is needed in this PR. The cause is the one described in #111985 (comment) (the |
…or secondary queries Address review: the guards for columns used by keys, indices and projections and for parts with a lazily changed `JSON` type hint checked only the storage read by the query. `Merge`, `MaterializedView`, `Buffer`, `Alias` and storage proxies forward the read with the requested subcolumns to underlying tables, whose keys and parts were not inspected. Now the guards are applied to every underlying storage as well, failing closed when it cannot be determined. `PushSubcolumnsIntoSubqueriesPass` is no longer run for secondary queries. The query sent to a shard or a parallel replica already carries the pushed subcolumns, and a second run is not idempotent: it lowered `isNull(c1.1)` over the pushed `c1.1` into `notEquals(c1.1.null, 0)`, so the header of the replica did not match the initiator (`NOT_FOUND_COLUMN_IN_BLOCK` in `04869_sparse_tuple_element_missing_column_read` with parallel replicas). https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=112688&sha=ffc1256b783d9f15d29e9d34d2951686474abb68&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Status 2026-10-30: merged current
|
… in the pushdown guard A row policy of a child of `Merge` (or of the target of a materialized view, `Buffer`, `Alias`, a proxy) is attached when the wrapper builds the read of that table, after the pushdown decision. `hiddenFilterReadsContainingColumn` now walks the underlying storages with `anyStorageReadFrom` and checks their effective row policies (with `ALIAS` expansion against their own metadata). If such a policy reads the whole column, the subcolumn is not pushed and is extracted from the value already read. Regression: `05462_push_subcolumns_into_subqueries_merge_child_row_policy`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…down Resolve the conflict in `QueryTreePassManager`: master added `runFrom` and a static `resolve_passes_count = 4`, while this PR computes the count of resolve passes dynamically (it includes `PushSubcolumnsIntoSubqueriesPass`). Keep the dynamic member, expose it via `getResolvePassesCount` and use it in `InterpreterSelectQueryAnalyzer`.
…onversions of wrappers - With `ROLLUP`, `CUBE` and `GROUPING SETS`, different grouping keys (`length(arr)` and `arr.size0`) replaced with the same pushed column were deduplicated, which changed the grouping sets and the masks of `grouping`. Keys are no longer replaced under these modifiers. - A `Buffer`, `MaterializedView` or `Merge` table can expose a column with another type than the storage it forwards the read to; reading the whole column converts it, while a forwarded subcolumn of the wrapper type (`n.null` of `Nullable(UInt8)` over `UInt8`) may not exist there, so `Buffer` silently skipped the destination. Such subcolumns are no longer pushed down. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=112688&sha=8fd4787f1cf25de5a059d13ab8dae204aaae112f&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%29 ( |
|
This is the Measured with
No separate PR from me. |
…s_into_subqueries_grouping_modifiers_and_wrapper_types` The `Buffer` table in the test has a column type that differs from its destination table on purpose, so the server logs a warning that the Fast test reports as unexpected stderr. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=112688&sha=4ea4a7224b9dae9a69edc62c3daadb0cad310aa6&name_0=PR&name_1=Fast%20test #112688 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Status 2026-11-02: pushed f22cdbf.
|
# Conflicts: # tests/queries/0_stateless/05337_parallel_join_max_joined_block_size.sql
|
🕵 The |
…ntoSubqueriesPass` The origins were collected after `runOnlyResolve`, which now includes `PushSubcolumnsIntoSubqueriesPass`. That pass can rewrite an expression over a subquery column (e.g. `length(a)` in `SELECT length(a) AS len FROM (SELECT a FROM t)`) into the subcolumn `a.size0`, so the MySQL metadata reported `org_table = t` and `org_name = a.size0` for a computed result. Now the origins are collected right after the passes that only resolve the query tree, before any pass that can rewrite an expression into a column. The MySQL metadata test covers the subquery case. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| /// plan. The pass is not idempotent: a function-form carrier over a pushed subcolumn | ||
| /// (`isNull(c1.1)` over the pushed `c1.1`) is lowered only by a second run, which would change the | ||
| /// header of the secondary query (`notEquals(c1.1.null, 0)`) and break the reading of its result. | ||
| if (context->getClientInfo().query_kind == ClientInfo::QueryKind::SECONDARY_QUERY) |
There was a problem hiding this comment.
[P1] Skip the non-idempotent pass when building local shard plans
Checking only SECONDARY_QUERY misses local shards: createLocalPlan copies the initiating context and uses ignoreASTOptimizations, so its query kind remains INITIAL_QUERY. The resolve-only range still executes this pass, lowering an already-pushed expression a second time and changing the aggregate header.
Reproduced on 69843c39deb1 with two localhost shards in local_two and default optimization settings:
CREATE TABLE raw (id UInt64, c1 Tuple(Nullable(Int32)))
ENGINE = MergeTree ORDER BY id;
INSERT INTO raw VALUES (0, (1)), (1, (NULL));
CREATE TABLE d AS raw
ENGINE = Distributed(local_two, currentDatabase(), raw);
SELECT sum(r.c1.1 IS NULL)
FROM d AS l CROSS JOIN (SELECT c1 FROM raw) AS r
WHERE l.id = 0
SETTINGS optimize_push_subcolumns_into_subqueries = 1;Pushdown disabled returns 2; enabled raises THERE_IS_NO_COLUMN: the initiator expects sum(isNull(...c1.1)), but the local plan produces sum(notEquals(...c1.1.null, 0)). Setting prefer_localhost_replica = 0 also restores the result. Please suppress this pass for already-optimized local shard plans as well, and cover this local execution path in a focused stateless regression.
| const auto & columns = storage_snapshot->metadata->getColumns(); | ||
| auto part_has_different_type = [&](const MergeTreeData::DataPartPtr & part) | ||
| { | ||
| for (const auto & part_column : part->getColumns()) |
There was a problem hiding this comment.
[P2] Avoid a full parts-and-columns scan for every candidate
This loops over every physical column of every active part for each candidate, including ordinary String columns. It runs during validateGroup, before the whole-column liveness guard can reject the rewrite. Consequently even a query whose plan remains unchanged pays O(candidates × parts × physical columns) work.
On the exact-head Fast test binary, a table with 1,000 compact parts and 129 columns (id plus 128 String columns), queried with EXPLAIN QUERY TREE SELECT c0, length(c0), ... c31, length(c31) FROM (SELECT * FROM t), takes a warm median 6 ms with pushdown disabled versus 79 ms enabled. None of the 32 candidates is ultimately pushed because the whole columns remain selected. The subcolumn-only variant also increases from 5 ms to 75 ms. These are analysis timings, without data reads.
Please resolve the relevant physical column once and inspect only its type, reuse safety-check results within the query, and avoid scanning parts when their layout cannot affect the rewrite. Add a focused analysis-time comparison for a wide table with many parts; the existing bytes-read regression does not exercise this cost.
|
@novikd provided a comment:
@groeneai, submit a PR with a complete re-implementation using @novikd's idea. |
|
Acknowledged. I'll submit an independent re-implementation as a query plan optimization on top of the volume-reducing functions push-down ( |
|
I opened #129422: it re-implements this as a query plan optimization inside |
Closes: #75538
Related: #92455
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Read only the requested subcolumns of columns exported by subqueries, CTEs and
UNION ALLbranches instead of the whole columns. Ordinary views benefit whenanalyzer_inline_views = 1. For example,SELECT data.a FROM (SELECT * FROM table)with aJSONcolumndatanow reads only the subcolumndata.afrom the table. Controlled by the new settingoptimize_push_subcolumns_into_subqueries(enabled by default).Documentation entry for user-facing changes
When a subcolumn of a column exported by a subquery is requested, it is resolved into the
getSubcolumnfunction over the whole column:SELECT data.a FROM (SELECT * FROM test)reads the wholedatacolumn from the table and extracts the subcolumn afterwards.The new query tree pass
PushSubcolumnsIntoSubqueriesadds the subcolumn to the subquery projection and replaces thegetSubcolumnfunction with a reference to it. If the whole column is not used anywhere else, it is then removed from the subquery projection by the subsequentRemoveUnusedProjectionColumnspass, so only the subcolumn is read from the table. The pushdown works through several levels of subqueries, CTEs andUNION ALLbranches, and also applies toTuple,Nullable,Arrayand other types with subcolumns. Ordinary views benefit whenanalyzer_inline_views = 1.UNION ALLsubqueries are supported: the subcolumn is added to every branch at the same position, all-or-nothing, and only when the branch types match exactly (the subcolumn of the least supertype is not guaranteed to be the supertype of the branch subcolumns). TheDISTINCT,INTERSECTandEXCEPTmodes deduplicate or match rows over all projection columns, so such subqueries are not rewritten (nor are recursive CTEs).The pushdown is skipped when it could change the query result:
DISTINCT,GROUP BY, aggregate functions, orORDER BY ... WITH FILL(an added projection column would change the result or would not be valid);JOINthat can be filled with default values for non-matched rows (getSubcolumnof a default value is not always equal to the default value of the subcolumn type, e.g. for thenullsubcolumn ofNullablecolumns); a shared subquery node (an ordinary CTE referenced several times) found in any such position is ineligible for all of its occurrences;getSubcolumnis only replaced when it is evaluated before the aggregation step (WHERE,JOIN ON, arguments of aggregate functions) or when the whole expression is an aggregation key (but not underROLLUP,CUBEandGROUPING SETS, where keys replaced with the same pushed column would be merged);Buffer,MaterializedView,Merge, ...) exposes the column with another type than the storage it forwards the read to;join_use_nullsorgroup_by_use_nulls;SELECT tup AS x, tup FROM t, or a trivialALIASstorage column next to its base column), and uses of an exported column the pushed subcolumn is a part of (SELECT x.b, tup FROM (SELECT tup.a AS x, tup FROM t), where the livetupexport already reads everythingtup.a.breads; an export of a sibling or of a deeper subcolumn does not block the pushdown, it reads less than the whole column): the subquery would then read both the whole column and the subcolumn from the table, while extracting the subcolumn from the already read column is cheaper. For aUNION ALLtarget the alias equivalence of exported names is detected in every branch (the pushdown is applied to all branches or to none), so a single branch exporting the same physical column under another name that stays alive blocks the rewrite. The decision counts only sibling subcolumns that are validated as actually pushable into the target (in a side-effect-free dry run): when two subcolumns of the same exported column are requested and only one of them can be pushed (e.g. the other is shadowed by a same-named storage column inside the subquery), nothing is pushed, since the unpushable sibling keeps the whole column alive.WHERE cityHash64(tup) > 0): the subcolumn is then extracted from the value that is read anyway;additional_table_filters, withALIAScolumns expanded) reads a column containing the pushed subcolumn;MergeTreetable some of whose parts store theJSONcolumn with another type than the metadata (after a lazy type hint change): a subcolumn read from such a part gives defaults (Lazy JSON type hint subcolumns return defaults on pre-ALTER parts #123339), so the subcolumn is extracted from the whole column there;MATERIALIZEDCTE (enable_materialized_cte): the temporary table serves all references of the CTE, so pruning the parent column there would require proving that no reference needs the whole column. Single-use materialized CTEs are inlined by the analyzer and take the ordinary subquery path (subcolumn reads over materialized CTEs are currently broken on master independently of this change, see Materialized CTE: subcolumn reads fail with NOT_FOUND_COLUMN_IN_BLOCK #113623).Besides the plain subcolumn reads (
getSubcolumn,tupleElement,variantElement,mapKeys,mapValues,m['key'],length,isNull), the forms thatFunctionToSubcolumnsrewrites into an expression over a subcolumn are pushed as well:empty/notEmptyof aString,ArrayorMapbecome a comparison of the size subcolumn with zero,isNotNullbecomesnotof thenullsubcolumn,mapContainsKeybecomeshasover thekeyssubcolumn,countof aNullablebecomessum(not(<column>.null)), andtupleElementof aQBitreads the bit-plane subcolumn.FunctionToSubcolumnsonly rewrites columns read directly from a table, and it runs after this pass, so without this these forms would keep reading the whole parent column through every subquery, CTE andUNION ALLlayer. Different functions of the same subcolumn share one pushed projection column, e.g.length(a)andempty(a)both read a singlea.size0. The remaining guards ofFunctionToSubcolumnsare mirrored: a function-form carrier (anything but a plaingetSubcolumn) is not rewritten into a direct subcolumn read of a table withFINAL, because the rewrite may alter the special merging algorithms (a plain subcolumn access stays pushable underFINAL— the analyzer itself resolves it into a direct subcolumn read there); the carrier origin of a pushedgetSubcolumnprojection is remembered, so the restriction survives multi-level pushdown.tupleElementwith a positional index over an unnamed tuple is not pushed into tuple-element-only readers that match the flattenedt.1against the real field names of a file (e.g.file(..., Parquet/ORC)with a positional structure hint). AMapwithEnumkeys converts the key (a name or a numeric value) through the enum before serializing the key subcolumn, and a value that is not a member is not rewritten; aStringkey whose length differs from aFixedStringmap key is not rewritten either, because the padded key would turn a missing-key lookup into a match. The chainedDynamic/JSON-array accessx.a[1].breads only the pathjson.athrough the ordinarygetSubcolumnpushdown; it is deliberately not rewritten intoarrayElementover the typed nested subcolumnjson.a.:`Array(JSON)`.b, because that subcolumn holds only the arrays stored asArray(JSON)and would lose the values of the other runtime alternatives of theDynamicpath (Array(Nullable(JSON)),Array(Dynamic), nested arrays).Subqueries spelled with an alias list, e.g.
SELECT x.a FROM (SELECT json FROM t) AS s(x), are supported. TrivialALIAScolumns (anALIASwhose body is just another column of the same table, possibly chained) exported by a subquery are followed down to the underlying storage column. A subquery can also export a derived subcolumn (e.g.SELECT json.a AS x FROM ...over a deeper subquery keeps agetSubcolumn(json, 'a')projection expression); reading a subcolumn of such an export composes the paths (a+b->a.b), so the pushdown continues through derived exports down to the base table. The composition is applied only when the flat name resolves to the same substreams and type as the structured extraction, so a sibling tuple element literally nameda.bor a typed JSON patha.Int64is never read instead. Conversely, when no name of such an alias-equivalent class of exports remains referenced in the outer queries, the never-referenced sibling exports are dead together with the replaced ones (all of them are removed byRemoveUnusedProjectionColumns), so they do not block the pushdown through the deeper levels of subqueries; the alias-equivalent classes are taken from every branch of aUNION ALLtarget.Workflow [PR]
Sync PR [sync-upstream/pr/112688]