Repository navigation
fix(types,executor): one family-capability table decides which statistic a family answers - #938
Merged
Merged
Conversation
…tic a family answers The SummaryEstimate validation, FamilyCapability::of and the executor's supported_summary_families each said which statistic a summary family answers, and they disagreed (Hll/Kmv total listed only by the executor, DDSketch total listed by the table and the executor but rejected by the IR). - SummaryEstimate validation asks FamilyCapability::answers; SketchCategory is deleted. - Table rows follow the current IR: DDSketch answers quantiles only; Count Sketch answers item frequency and total (not L2); the heap families answer top-k only. - The executor follows the table: validate_sketch_evaluation and supported_summary_families read FamilyCapability, less an explicit list of readouts it does not evaluate yet. HLL, KMV and DDSketch kernels no longer answer a bare point count. - merged_error has no default for an unanswered statistic. Closes #937 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Count Sketch's signed counters give no total, and neither the executor nor asap_sketchlib keeps one: its table row answers item frequency only, and Pass 1 no longer offers it for a count. The HydraCms group-total error names its Hydra kind; of_sketch is renamed of_per_instance_sketch. The primitive-schema design doc drops SketchCategory and the stale rollup readouts. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
3 tasks
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.
Closes #937.
Why
Which statistic a summary family answers had three sources of truth, and they disagreed (#937):
FamilyCapability::of(IR types)SummaryEstimatevalidationsupported_summary_familiesA deployment declaring the executor's list told the Planner that an HLL answers a total the IR refuses, and planner rules that read the table (CSE sharing, merged-pane guarantees) believed a DDSketch answers a total the IR rejects. The executor's
validate_sketch_evaluationheld a fourth, hand-written copy.What
One table at the IR layer,
FamilyCapability::of, decides which statistic a family answers. The IR validation and the executor follow it. The table follows the current IR: no IR-accepted plan changes, except where the table intentionally fixes a row (listed below).Changed rows
Family-capability table (
crates/types/src/ir/schema/family_capability.rs), per-instance states:asap_sketchlibkeeps oneUnchanged: Kll, Cms (ItemFrequency, Total), Hll and Kmv (Distinct), UnivMon (Total, Distinct, FrequencyL2, FrequencyEntropy), Theta, and the three Hydra rows.
Executor list (
supported_summary_families), now derived from the table:Other families are unchanged. Cms keeps
[Total]: its per-instance item frequency is in the table but listed inUNEVALUATED_READOUTS(the executor reads an item's frequency only from a Hydra grid).IR validation: what changes
Old category match versus the table, over every family and statistic (pinned by
estimate_validation_matches_the_category_match_except_the_fixed_rows). The table's existing rows already said these, and the executor agrees:Universalcategory accepted every point count and top-k).asap_sketchlib's Hydra).Every other (family, statistic) pair keeps its old answer, including the DDSketch total (still rejected).
How
SummaryEstimatevalidation callsFamilyCapability::of(family).answers(query)for a sketch state; non-sketch states are still rejected.SketchCategory,SketchKind::category()and thecategoryfield are deleted: nothing else read them. SerializedSketchKindJSON loses itscategorykey; old JSON still deserializes, because unknown keys are ignored.realization.rssummary_candidates): Count-Min and UnivMon remain.FamilyCapability::of_per_instance_sketch(algorithm)returns a per-instance family's row.ofdelegates to it, so the executor can read a row without sketch parameters.validate_sketch_evaluationaccepts a statistic exactly when the table answers it and the executor evaluates that readout. Evaluated readouts are the families inEVALUATED_FAMILIES(HydraCms/HydraKll for Hydra) lessUNEVALUATED_READOUTS. It keeps the quantile-range check and the HydraCms group-total message (raised only for a HydraCms family). Top-k stays with the keyed evaluation.supported_summary_familiesis the table row of each evaluated family, less those readouts.PointCount. Nothing reached that path, because the IR never accepted it.merged_errordrops its default for a statistic the family does not answer and returnsNoneinstead. Every caller passes an IR-valid estimate, which the table answers. The default existed only for Count Sketch's count, which Pass 1 no longer offers.Key code interfaces added / modified
crates/types/src/ir/schema/family_capability.rscrates/types/src/ir/schema/sketch.rscrates/executor/src/capability.rscrates/executor/src/supported_summaries.rsUsage (end to end, as the tests exercise it):
Before this PR
The IR validated
SummaryEstimatebySketchCategory. The table and the executor list were separate hand-maintained copies. They disagreed on DDSketch, Hll and Kmv totals, Count Sketch L2 and total, heap item frequencies, UnivMon item frequency and top-k, and Hydra group totals. The executor's HLL/KMV "total" was the distinct count.After this PR
There is one table at the IR layer. The IR validation, the executor's evaluation check and its supported list all read it, and a test fails when any of them diverge. Plan selection results are unchanged on the existing suites.
Verification
estimate_validation_matches_the_category_match_except_the_fixed_rowsandsupported_summary_families_match_the_factory_and_evaluationsfail; with this change they pass.asap-types:estimate_validation_matches_the_category_match_except_the_fixed_rows,a_statistic_the_family_does_not_answer_is_rejected(DDSketch total, HLL total, quantile over Count-Min, top-k over KLL, exact accumulator),family_capability_table,merged_error_depends_on_the_readout,summary_capability_facts.asap-executor:supported_summary_families_match_the_factory_and_evaluationsnow also checks that the IR builds exactly what the table answers, and that the table answers exactly what the executor evaluates for every family it evaluates, except the named unevaluated readouts. It also checks that each accepted evaluation's kernel really reads the readout from a built state.a_count_offers_no_count_sketch: no Count Sketch among a count's candidates, and every offered summary answers the total. Table tests pin that Count Sketch does not answer a total.a_readout_the_deployment_cannot_answer_prunes_its_familyandmulti_measure_aggregate_has_one_target_per_measureintests/per_computation_candidates.rsdrop the Count Sketch candidate from the expected lists.combinations_skip_choices_a_whole_expression_candidate_absorbsnow expects 5 combinations instead of 6, because the inner count has 3 candidates (accumulator, Count-Min, UnivMon) instead of 4; its structural assertions are unchanged.a_count_from_count_sketch_panes_keeps_its_guaranteeis nowa_count_from_count_min_panes_keeps_its_guarantee: it checks the same merged-pane property with Count-Min.cargo nextest run -p asap-types -p asap-executor -p asap-logical-asap-optimization -p asap-plan-selection: 1218 passed, 0 failed. No plan-selection expectation changed.cargo fmt --all -- --check,cargo clippy -p asap-types -p asap-executor -p asap-logical-asap-optimization --all-targets -- -D warnings: clean.cargo check --workspace --all-targets: clean.asap-integration-testsandasap-devtoolstest binaries. The build host's disk filled while linking them; they compile (cargo check --all-targets).Design doc
docs/design_docs/proposals/asap-primitive-schema.mddropsSketchCategoryandSketchKind.category/category(). Its rollup table no longer lists a DDSketch total, Count Sketch L2, or heap item frequencies, and the approximate-count row lists Count-Min and UnivMon only.Follow-ups (not in this PR)
realization.rs) agree with the table: every offered family answers its intent's statistic. They are an ordered preference list, not a second capability table, so they stay.tools/dag-viewer/examples/*.json) still carrySketchKind's removedcategorykey; they still load (unknown keys are ignored) and should be regenerated.🤖 Generated with Claude Code
CI regression fix
Scenario:
count by (job) (m)with undeclared deployment summaries. Before this follow-up, the stage-pipeline test expected CountSketch to be generated and then deployment-pruned. After the capability change it is correctly never generated, so the pruning report is empty. The test now checks that empty report while preserving the supported candidate and executor-default assertions. Reproduced the failure locally before the change; the unchanged command passes afterward. No production behavior or accuracy target changed.Local CI-fix verification: all 47 stage-pipeline tests passed, including the nine-query installation and workload-example acceptance tests. Strict devtools stage-pipeline clippy, formatting, and diff checks passed. Full remote CI is pending.
Additional verification: full
cargo test -p asap-integration-testspassed: 324 passed, 0 failed, 23 ignored.Second CI regression: PromQL
count/count_over_timeunit-weight tests still required CountSketch. Reproduced failure locally, then changed the expected supported summaries to CMS and UnivMon and explicitly rejected CountSketch; physical DAG update-contract assertions remain. All count-planning tests pass (7 passed, 1 existing ignored), with strict clippy. Full workspace validation is running.