Skip to content

feat(sketch_db): fold sketch_kind/sketch_config into agg_kind - #154

Merged
zzylol merged 1 commit into
mainfrom
feat/instance-meta-aggkind
May 13, 2026
Merged

zzylol merged 1 commit into
mainfrom
feat/instance-meta-aggkind

Conversation

@zzylol

@zzylol zzylol commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Phase 5 M2.3.2 — replaces the M2-era sketch_kind+sketch_config field pair on SketchInstanceMetadata with a single agg_kind: AggKind. Same struct can now describe either a sketch-backed sid (AggKind::Sketch { kind, config }) or a precompute-backed sid (AggKind::Precompute { agg_type, parameters_canonical } — wired up in M2.3.3+).

  • capability: Option<Capability> and accuracy: Option<AccuracyBound> (None for exact precomputes).
  • sketch_kind() / sketch_config() accessor methods return Option<_>. The warm-tier reducer (sketch-only) keeps working with a thin .expect("only handles sketches") — upstream instances_matching already filters precompute sids out.
  • Defensive Option<Capability> handling in sketch_reducer::require_capability surfaces a None as UnsupportedCapability rather than panicking.

Test plan

  • cargo test -p data_plane --lib --no-fail-fast — 798/800 pass (2 pre-existing schema_timeline_dispatch_tests failures unrelated).
  • cargo check --workspace clean.
  • 32 errors remain in data_plane/tests/e2e_modified_otlp_sketch_path.rs — pre-existing struct-field-removed errors documented in the prior session summary; not in scope.

🤖 Generated with Claude Code

…chInstanceMetadata

Phase 5 M2.3.2 — replaces the M2-era `sketch_kind: SketchKindHandle`
+ `sketch_config: SketchConfig` field pair on `SketchInstanceMetadata`
with a single `agg_kind: AggKind`. Same struct can now describe
either a sketch-backed sid (`AggKind::Sketch { kind, config }`) or a
precompute-backed sid (`AggKind::Precompute { agg_type,
parameters_canonical }`) — the latter lights up in M2.3.3+.

`capability: Option<Capability>` and `accuracy: Option<AccuracyBound>`
because precomputes answer exact statistics and have no warm-tier
approximation profile. The warm-tier reducer (sketch-only) handles a
`None` capability as a defensive `UnsupportedCapability` rather than
a panic.

`sketch_kind()` and `sketch_config()` accessor methods return
`Option<_>` so existing sketch-only consumers (`sketch_reducer.rs`)
keep working with a thin `.expect("only handles sketches")` —
upstream classification already filters precompute sids out of the
reducer's caller list.

8 ingest + test construction sites updated. 798/800 lib tests pass
(the 2 pre-existing `schema_timeline_dispatch_tests` failures
predate this PR).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol
zzylol merged commit 3964ba6 into main May 13, 2026
@zzylol
zzylol deleted the feat/instance-meta-aggkind branch July 17, 2026 20:05
zzylol added a commit that referenced this pull request Jul 22, 2026
ASAPController#146 (CostModel::size_params) and #154 (bind::logical
visibility) are both merged. Re-pin from the feat/costmodel-size-params-hook
branch tip to main's current commit now that both land there.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
zzylol added a commit that referenced this pull request Jul 22, 2026
…#408)

* feat(control_plane): adopt asap_sketch::L4Node for the L4 IR (Step B)

Retires control_plane's own locally-defined, flat PhysicalExpr L4 algebra
(Logical/SketchAgg/SketchEstimate/SketchMerge/ExactAgg) in favor of
ASAPController's canonical L4 IR, asap_sketch::{SummaryExpr, L4Node} --
the same move Step 3 of the enum-unification made for
SketchKind -> SummaryKind, one layer up.

PhysicalExpr is now a thin L5 wrapper: `Committed(L4Plan)` for the
common case, plus the two Phase eps.1 placement variants. L4Plan keeps
only what asap_sketch genuinely doesn't have -- named LetBinding/Ref
fan-in sharing (asap_sketch's own DAG sharing is structural, via Rc, but
this crate's rule-firing walk still needs a name to thread a bound value
across sibling calls).

The 7 bind_kll_quantile/bind_ddsketch_quantile/bind_hll_cardinality/
bind_cms_count/bind_cms_topk/bind_exact_agg/bind_archive_only Rule
structs are retired -- their selection/sizing policy (KLL's k rungs,
DDSketch-over-KLL priority, TopK recall tiers, wire-cost tie-breaks) is
preserved verbatim in the new ControlPlaneCostModel, plugged into
asap_plan::bind::implement_tree_in_with via the CostModel trait
(rank_candidates + the new size_params hook, ASAPController#146) instead
of a bespoke dispatcher -- so schema derivation, col/by computation, and
DAG construction are asap_plan::bind's, not a forked copy.

Three node shapes get a small local pre-pass in sketch_algebra::lower
before delegating, because asap_plan::boundary::implementation_for
actively binds them to something this deployment's data plane can't (or
deliberately shouldn't) serve:
- AggIntent::Count{accuracy: Exact} would bind SummaryKind::Count, which
  has no data-plane accumulator (PR #200/#201 already established this
  is wrong -- reverted, stays on archive).
- AggIntent::Rate would bind its own SummaryKind::Rate; this deployment
  represents Rate as an Increase accumulator (rate = increase / window,
  a query-time division, not a separate accumulator).
- AggIntent::Extension (Frequency) and TopK{accuracy: Exact} both
  decline to bind at all (asap_plan's Extension/exact-TopK coverage gaps
  -- filed upstream as ASAPController#150 and #151); this is a real,
  accepted behavior change from the retired bind_cms_count/bind_cms_topk
  rules, not a bug -- see the updated tests in optimizer/rules/mod.rs
  and emit/mod.rs.

Also fixes a real bug surfaced by the migration: PhysicalExpr now
carries Rc<L4Node> (asap_sketch's own DAG-sharing mechanism), so holding
a bound PhysicalExpr across an .await point made handle_plan's generated
Future !Send, breaking axum::Handler. Scoped the Rc-bearing computation
into a synchronous block that resolves down to Send-safe StageConfig
output before the first await.

Pins ASAPQuery-backend's ASAPController dependency to
12482fd77945ab5771a021c6112750fd9284f8ed (ASAPController PR #146,
CostModel::size_params + bind::logical).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* chore: re-pin ASAPController to main (post #146/#154 merge)

ASAPController#146 (CostModel::size_params) and #154 (bind::logical
visibility) are both merged. Re-pin from the feat/costmodel-size-params-hook
branch tip to main's current commit now that both land there.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant