Match a plain explode against an explode with ordinality - #4619
Draft
g31pranjal wants to merge 2 commits into
Draft
g31pranjal wants to merge 2 commits into
g31pranjal wants to merge 2 commits into
Conversation
g31pranjal
added this pull request to stack #4620
September 14, 2026 15:01
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/synthetic-type-expand
branch
from
September 14, 2026 15:11
e93765d to
5972e75
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
2 times, most recently
from
September 14, 2026 15:59
457737a to
802b25c
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/synthetic-type-expand
branch
2 times, most recently
from
September 15, 2026 10:07
9186c7b to
d4ebb50
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
from
September 15, 2026 10:07
802b25c to
66106af
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/synthetic-type-expand
branch
from
September 15, 2026 13:46
d4ebb50 to
70913fd
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
from
September 15, 2026 13:46
66106af to
cd8ca19
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/synthetic-type-expand
branch
from
September 16, 2026 11:10
70913fd to
51f14cb
Compare
Base automatically changed from
apple/g31pranjal/unnested/synthetic-type-expand
to
apple/g31pranjal/unnested/zero-based-ordinality
September 16, 2026 11:10
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
from
September 16, 2026 11:10
cd8ca19 to
fe9b6d2
Compare
g31pranjal
removed this pull request from stack #4620
September 16, 2026 11:12
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
changed the base branch from
apple/g31pranjal/unnested/zero-based-ordinality
to
apple/g31pranjal/unnested/synthetic-type-expand
September 16, 2026 13:16
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/synthetic-type-expand
branch
from
September 16, 2026 13:16
51f14cb to
40cfe34
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
from
September 16, 2026 13:16
fe9b6d2 to
4e19391
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/synthetic-type-expand
branch
from
September 16, 2026 13:35
40cfe34 to
28a0ea8
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
from
September 16, 2026 13:35
4e19391 to
4fb7006
Compare
g31pranjal
changed the base branch from
apple/g31pranjal/unnested/synthetic-type-expand
to
apple/g31pranjal/unnested/zero-based-ordinality
September 16, 2026 13:36
g31pranjal
added this pull request to stack #4629
September 16, 2026 13:36
📊 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
force-pushed
the
apple/g31pranjal/unnested/zero-based-ordinality
branch
from
September 16, 2026 18:55
c597cea to
0848c7b
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
from
September 16, 2026 18:55
4fb7006 to
b7db6bc
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/zero-based-ordinality
branch
from
September 16, 2026 20:29
0848c7b to
69399ce
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
from
September 16, 2026 20:29
b7db6bc to
1818a02
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/zero-based-ordinality
branch
from
September 16, 2026 21:21
69399ce to
b1a40b3
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
from
September 16, 2026 21:21
1818a02 to
f4a7009
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/zero-based-ordinality
branch
from
September 16, 2026 23:11
b1a40b3 to
dd4d868
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
from
September 16, 2026 23:11
f4a7009 to
d84e4be
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/zero-based-ordinality
branch
from
September 17, 2026 14:22
dd4d868 to
a8f0925
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
from
September 17, 2026 14:22
d84e4be to
92aaead
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/zero-based-ordinality
branch
from
September 17, 2026 22:34
a8f0925 to
2a64cc4
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
from
September 17, 2026 22:34
92aaead to
2979d09
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/zero-based-ordinality
branch
from
September 17, 2026 22:39
2a64cc4 to
d4a521c
Compare
Base automatically changed from
apple/g31pranjal/unnested/zero-based-ordinality
to
apple/g31pranjal/unnested/synthetic-type-expand
September 17, 2026 22:39
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
from
September 17, 2026 22:39
2979d09 to
c781f27
Compare
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
An explode `WITH ORDINALITY` flows an anonymous `(element, ordinal)` struct. Until now the value standing for that struct was a single opaque `QueriedValue`, which made the element unreachable to `MaxMatchMap`: it descends into record constructors, but an opaque value offers nothing to match against but itself. A query that explodes a collection plainly therefore had no correspondence to a candidate that explodes the same collection with ordinality, and any such match was lost. `ExplodeExpression.explodeResultValue` now builds the ordinality variant as a `RecordConstructorValue` of two `QueriedValue`s. The element stays the first column deliberately: `MaxMatchMap` takes the first reachable candidate value that compares equal, and a `QueriedValue` compares equal to any other, so an element would just as happily match the ordinal if the ordinal came first. The record is built nullable so its type stays the one `explodeResultType` already declares -- that type backs the protobuf descriptor the plan builds at run time. Because a `QueriedValue` was equal to every other `QueriedValue` regardless of type, the two columns of that record were indistinguishable, and pulling a value up through the explode found both. `QueriedValue.equalsWithoutChildren` now also compares the result type. `subsumedBy` gains the case itself: a plain explode is subsumed by an explode with ordinality over the same collection, since the candidate produces at least everything the query may produce. `exactlySubsumedBy` cannot express it, as its `equalsWithoutChildren` compares `isWithOrdinality`.
`RecordMetaData.getPlannerType` resolves a name against the stored record types only, so it cannot describe a synthetic record type. Add overloads that take the `RecordType`s themselves, which is what `recordTypesForIndex` hands back for an index defined on a synthetic type, and let the name-taking ones delegate to them. This is what expanding an index defined on an unnested record type into a match candidate needs in order to describe the type the candidate flows.
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/synthetic-type-expand
branch
from
September 18, 2026 15:12
24551d6 to
a74faf7
Compare
g31pranjal
force-pushed
the
apple/g31pranjal/unnested/explode-ordinality-matching
branch
from
September 18, 2026 15:12
c781f27 to
f3be10b
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.
An explode
WITH ORDINALITYflows an anonymous(element, ordinal)struct. Untilnow the value standing for that struct was a single opaque
QueriedValue, whichmade the element unreachable to
MaxMatchMap: it descends into recordconstructors, but an opaque value offers nothing to match against but itself. A
query that explodes a collection plainly therefore had no correspondence to a
candidate that explodes the same collection with ordinality, and any such match
was lost.
ExplodeExpression.explodeResultValuenow builds the ordinality variant as aRecordConstructorValueof twoQueriedValues. The element stays the firstcolumn deliberately:
MaxMatchMaptakes the first reachable candidate value thatcompares equal, and a
QueriedValuecompares equal to any other, so an elementwould just as happily match the ordinal if the ordinal came first. The record is
built nullable so its type stays the one
explodeResultTypealready declares --that type backs the protobuf descriptor the plan builds at run time.
Because a
QueriedValuewas equal to every otherQueriedValueregardless oftype, the two columns of that record were indistinguishable, and pulling a value
up through the explode found both.
QueriedValue.equalsWithoutChildrennow alsocompares the result type.
subsumedBygains the case itself: a plain explode is subsumed by an explode withordinality over the same collection, since the candidate produces at least
everything the query may produce.
exactlySubsumedBycannot express it, as itsequalsWithoutChildrencomparesisWithOrdinality.