Expand an unnested record type into a Cascades graph - #4626
Open
g31pranjal wants to merge 4 commits into
Open
g31pranjal wants to merge 4 commits into
g31pranjal wants to merge 4 commits into
Conversation
g31pranjal
added this pull request to stack #4627
September 16, 2026 11:19
g31pranjal
removed this pull request from stack #4627
September 16, 2026 13:16
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/opt-in-zero-based-ordinality
branch
from
September 16, 2026 13:16
4d2d403 to
9b5aca6
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/synthetic-type-expand
branch
from
September 16, 2026 13:16
51f14cb to
40cfe34
Compare
g31pranjal
added this pull request to stack #4628
September 16, 2026 13:17
g31pranjal
removed this pull request from stack #4628
September 16, 2026 13:35
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/opt-in-zero-based-ordinality
branch
from
September 16, 2026 13:35
9b5aca6 to
f1509aa
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/synthetic-type-expand
branch
from
September 16, 2026 13:35
40cfe34 to
28a0ea8
Compare
g31pranjal
added this pull request to stack #4629
September 16, 2026 13:36
Base automatically changed from
apple/g31pranjal/unnested/opt-in-zero-based-ordinality
to
main
September 16, 2026 18:55
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/synthetic-type-expand
branch
4 times, most recently
from
September 17, 2026 14:22
03556e0 to
91b08d7
Compare
g31pranjal
marked this pull request as ready for review
September 17, 2026 14:22
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/synthetic-type-expand
branch
from
September 17, 2026 22:34
91b08d7 to
b8c1fb4
Compare
g31pranjal
removed this pull request from stack #4629
September 17, 2026 22:35
g31pranjal
added this pull request to stack #4632
September 17, 2026 22:35
g31pranjal
removed this pull request from stack #4632
September 17, 2026 22:39
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/synthetic-type-expand
branch
from
September 17, 2026 22:39
b8c1fb4 to
24551d6
Compare
📊 Metrics Diff Analysis ReportSummary
ℹ️ About this analysisThis automated analysis compares query planner metrics between the base branch and this PR. It categorizes changes into:
The last category in particular may indicate planner regressions that should be investigated. |
g31pranjal
changed the base branch from
main
to
apple/g31pranjal/unnested/zero-based-ordinality
September 17, 2026 22:43
g31pranjal
added this pull request to stack #4634
September 17, 2026 22:44
g31pranjal
removed this pull request from stack #4634
September 17, 2026 22:48
Adds `SyntheticRecordType.expand`, which turns a synthetic record type into the graph that assembles its records, and implements it for `UnnestedRecordType`: a select over the parent record's scan joined with one explode per nested constituent, whose result columns are the constituents plus the `__positions` field the synthetic primary key needs. The explodes are created `WITH ORDINALITY`, because a stored position is exactly the ordinal of the element within its owner's array, and there is no other way to recover it. The ordinals only need widening from the `INT` the explode flows to the `LONG` the `Positions` message declares -- the types have to agree, or the record the expansion flows is not of the type's own planner type. `RecordMetaData` gains `getPlannerTypeForRecordType(s)` overloads that take already-resolved `RecordType`s. The existing name-based overloads resolve against stored record types only, so they cannot describe a synthetic type, whereas `recordTypesForIndex` hands back the type itself for an index defined on one. This is groundwork: nothing calls `expand` yet. It is what lets a value index defined on a synthetic type become a match candidate, so that a query performing the same unnesting by hand can be answered from the index.
Covers the graph `UnnestedRecordType.expand` builds -- the parent scan, one explode per nested constituent, the `__positions` record, chained constituents and nullable-array wrappers -- and the record-type-taking planner type overloads, including that they describe a synthetic type, which the name-taking ones cannot. Adds `test_records_nested_chain.proto` for the chained case. The existing two-level proto, `test_records_double_nested.proto`, is deliberately recursive, and the planner cannot build a type for a recursive descriptor, so a chain of constituents needs a non-recursive record type to unnest.
g31pranjal
changed the base branch from
apple/g31pranjal/unnested/zero-based-ordinality
to
main
September 18, 2026 15:06
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/synthetic-type-expand
branch
from
September 18, 2026 15:12
24551d6 to
a74faf7
Compare
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.
Adds
SyntheticRecordType.expand, which turns a synthetic record type into the graph that assembles its records, and implements it forUnnestedRecordType: a select over the parent record's scan joined with one explode per nested constituent, whose result columns are the constituents plus the__positionsfield the synthetic primary key needs.The explodes are created
WITH ORDINALITY, because a stored position is exactly the ordinal of the element within its owner's array, and there is no other way to recover it. They ask for 0-based ordinals (the pull request below this one); it then only needs widening from theINTthe explode flows to theLONGthePositionsmessage declares.This is groundwork: nothing calls
expandyet. It is what lets a value index defined on a synthetic type become a match candidate, so that a query performing the same unnesting by hand can be answered from the index.