Skip to content

Route aggregate index plan breadcrumb values through the match candidate - #4550

Merged
hatyo merged 2 commits into
mainfrom
apple/hatyo/aggregate-plan-breadcrumbs
Sep 4, 2026
Merged

Route aggregate index plan breadcrumb values through the match candidate#4550
hatyo merged 2 commits into
mainfrom
apple/hatyo/aggregate-plan-breadcrumbs

Conversation

@hatyo

@hatyo hatyo commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Towards #3367. RecordQueryAggregateIndexPlan holds a resultValue and a groupByResultValue that nothing in the plan itself needs — both are breadcrumbs for later planner logic, and both are reachable through the plan's match candidate. Neither is read by the plan any more: getGroupingValueMaybe() is gone, and CardinalitiesProperty, its only reader anywhere in the repo, derives the grouping value from the AggregateIndexMatchCandidate instead. The two fields survive purely to keep the VC0 wire format intact, which is what the remaining todos track — they come out once the plan hash mode is bumped.

Under PlanHashMode.VC1 the plan hashes and serializes only the result type rather than the whole value, and fromProto rebuilds a QueriedValue from it; the group-by result value is not written at all, and deserialization substitutes a ThrowsValue so that an accidental reader fails loudly rather than quietly seeing the wrong thing. VL0 and VC0 keep hashing and writing both values, so existing continuations stay valid. Worth a reviewer's eye: VC1 is opt-in and CURRENT_FOR_CONTINUATION is still VC0, so the default path is untouched, but a deployment already running VC1 would see outstanding aggregate-index continuations fail validation — if the team counts that as user-visible, breaking change is the better label than enhancement.

@hatyo hatyo added enhancement New feature or request Run mixed-mode Label to add to Pull Requests to have it run mixed mode tests labels Sep 3, 2026
@hatyo
hatyo force-pushed the apple/hatyo/aggregate-plan-breadcrumbs branch from 744e099 to d673a3d Compare September 3, 2026 15:59
@hatyo
hatyo marked this pull request as ready for review September 3, 2026 16:00
@hatyo
hatyo force-pushed the apple/hatyo/aggregate-plan-breadcrumbs branch from d673a3d to 561414f Compare September 3, 2026 16:26

@alecgrieser alecgrieser left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I think I agree with the approach here regarding backwards (in)compatibility, namely that VC1 is not "current" yet, and so breaking it is fine

`RecordQueryAggregateIndexPlan` holds a `resultValue` and a `groupByResultValue`
that nothing in the plan itself needs: both are breadcrumbs for later planner
logic and both are reachable through the plan's match candidate. Neither is read
by the plan any more -- `getGroupingValueMaybe()` is gone, and
`CardinalitiesProperty`, its only reader anywhere in the repo, derives the
grouping value from the `AggregateIndexMatchCandidate` instead. The two fields
survive only to keep the `VC0` wire format intact, hence the `todo`s to drop
them once the plan hash mode is bumped.

Under `PlanHashMode.VC1` the plan hashes and serializes only the result type
rather than the whole result value, and `fromProto` rebuilds a `QueriedValue`
from it. The group-by result value is not written at all under `VC1`, and
deserialization substitutes a `ThrowsValue` so an accidental reader fails loudly
instead of quietly seeing the wrong thing. `VL0` and `VC0` keep hashing and
writing both values, so existing continuations remain valid.

Addresses #3367
@hatyo
hatyo force-pushed the apple/hatyo/aggregate-plan-breadcrumbs branch from 561414f to f604938 Compare September 4, 2026 12:48
@hatyo
hatyo merged commit 12a0a32 into main Sep 4, 2026
22 checks passed
@hatyo
hatyo deleted the apple/hatyo/aggregate-plan-breadcrumbs branch September 4, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Run mixed-mode Label to add to Pull Requests to have it run mixed mode tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants