Repository navigation
test: assert which sub-aggregation groupings use missing aggregations - #1456
Merged
Merged
Conversation
Collaborator
Author
|
This change is part of the following stack: Change managed by git-spice. |
missing aggregations
A grouping without a missing value placeholder needs a separate `missing` aggregation at every sub-aggregation level, so the number of aggregations grows exponentially. These assertions record which groupings do that today, so changes to placeholder handling show up in the specs. - Add `missing_aggregation_field_paths_from_queries`, which reads the recorded msearch requests, and `expect_last_query_to_use_missing_aggregations_on`, which asserts on the last search. - Add an `after` hook that fails any datastore test whose searches use `missing` aggregations, unless the test has the `:expect_missing_aggregations` tag. - Assert on it in the sub-aggregation acceptance specs (term, date histogram, `as_day_of_week`, `as_time_of_day` and geo tile groupings), in the `DatastoreQuery` sub-aggregation integration spec, and in the Apollo entity ref sub-aggregation spec. On `main`, `Boolean`, entity ref, date histogram, script term and geo tile groupings use `missing` aggregations. - Add a `SeasonResult` enum field to `TeamSeason` so the specs cover grouping on an enum in a sub-aggregation. Generated with Claude Code
myronmarston
force-pushed
the
myron/assert-missing-aggregations
branch
from
November 11, 2026 01:26
4213d33 to
713d132
Compare
myronmarston
marked this pull request as ready for review
November 11, 2026 01:44
myronmarston
requested review from
BrianSigafoos-SQ,
bsorbo,
ellisandrews-toast,
jwils,
jwondrusch,
marcdaniels-toast and
rossroberts-toast
as code owners
November 11, 2026 01:44
bsorbo
approved these changes
Nov 12, 2026
myronmarston
added a commit
that referenced
this pull request
Nov 12, 2026
… fields more efficient (#1461) **Why.** Make sub-aggregation queries that group on leaf-backed object fields (such as the Apollo entity refs from #1453) as efficient as other scalar groupings. A grouping without a missing value placeholder needs a separate `missing` aggregation at every level of a sub-aggregation, so the number of aggregations grows exponentially and can exceed the max clause count (#882). This is an alternative to #1454, which fixes the same bug by recording a type name on every leaf index field (about 640 lines per `runtime_metadata.yaml`). This PR records the type name only on the grouped-by fields of object-typed fields backed by a leaf index field: 6 lines in `artifacts_with_apollo` and 1 in `artifacts`. Stacked on #1456, which adds the assertions on `missing` aggregations that this PR updates. **How.** The schema definition records the type of the backing leaf index field. The GraphQL layer looks up that type and uses its existing missing value placeholder, so placeholder resolution (`$SECURE_RANDOM_VALUE`, enums) stays in `Schema::Type`. - `GraphQLField` runtime metadata gets an optional `object_grouping_leaf_type_name`. - `Field#define_grouped_by_field` sets it when the original field has an object type and the grouped-by field's `name_in_index` resolves, from the original field's parent type, to a leaf index field. - The path lookup from `backing_indexing_field` moves to `HasIndices#indexing_field_at`, so the grouped-by code can resolve the grouped-by field's `name_in_index` from the original field's parent type. `f.backing_indexing_field` can't be used: it resolves from the derived `GroupedBy` type, which has no indexing fields. - `Schema::Field#object_grouping_leaf_type` looks up the type (nil when unset), and the query adapter uses that type's placeholder for the grouping on a leaf-backed field. **Verification.** The Apollo entity ref test from #1456 no longer uses a `missing` aggregation. The leaf-backed query adapter tests, including a new `Boolean` case with no placeholder, fail without the fix. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
Why. A sub-aggregation nests one level per grouping field. A grouping without a missing value placeholder needs a separate
missingaggregation at every level, so the number of aggregations grows exponentially and can exceed the max clause count (#882). Nothing asserted which groupings do that, so a regression in placeholder handling would return the same results and pass every spec. #1461 builds on these assertions.missing_aggregation_field_paths_from_queriesreads the recorded msearch requests and returns, for each search, the field paths that have amissingaggregation.missingaggregations, becausecompositehas its ownmissing_bucketoption.main, the entity ref grouping uses amissingaggregation onsponsor_id.SeasonResultenum field onTeamSeasoncovers grouping on an enum in a sub-aggregation. No sub-aggregation in the test schema grouped on an enum before.Verification. The specs pass on
main, where only theBooleanand entity ref groupings usemissingaggregations. In #1461, the entity ref assertion changes to expect nomissingaggregation.🤖 Generated with Claude Code