Skip to content

Pass 1 offers CountSketch for a count, but the executor cannot evaluate a CountSketch total #727

Open

Description

@zzylol

Problem, by example

stage_pipeline --table '{"name":"metrics","columns":[{"name":"ts","type":"timestamp","nullable":false},{"name":"service","type":"utf8","nullable":false}],"time_index":0}' \
  --sql "SELECT COUNT(*) FROM metrics" --epsilon 0.01 --delta 0.001
  • Stage 1 lists L3 Q1 CountSketch.
  • Stage 3 marks P3 valid ("accepted absolute_stream_l2 (CountSketch)", cost 0.00254/s, against 0.0000733/s for exact P1). P3 is only rejected because it costs more.
  • If P3 were selected (for example, if the exact plan were priced higher), lowering would fail. validate_sketch_evaluation (crates/asap-physical-operators/src/capability.rs) accepts a bare PointCount { value: None } only for Count-Min, Hll, Kmv, DDSketch and UnivMon; for CountSketch it returns "evaluation is not implemented for this summary family".

Expected: no CountSketch candidate for a count, or a CountSketch total the executor can evaluate.

Cause

  • realizations_for_intent (crates/asap-aware-mapping/src/realization.rs) maps AggIntent::Count to [Cms, CountSketch, UnivMon].
  • The CountSketch accuracy model (count_sketch_l2_median_binomial_v1) then gives the total a single-item point-query bound, ε‖f‖₂, which is not a contract for a total.
  • The family-capability table has no (Total, …) row for CountSketch. Its merged_error keeps a fallback default for unanswered statistics only so that this candidate's paned guarantee stays as it was.

Proposal

Drop CountSketch from AggIntent::Count. A CountSketch's signed counters don't add up to the total, and Count-Min and UnivMon already cover counts. Then remove the merged_error fallback, so a statistic the family doesn't answer fails closed (None).

The alternative is an executor kernel plus an accuracy contract for a CountSketch total, and then a (Total, AsIfBuiltOverUnion) row.

Scope / acceptance

  • The example above lists no CountSketch candidate.
  • merged_error returns None for any statistic outside the family's row, and the family_capability_table test asserts it for every row.
  • Examples 1–4 select the same plans at the same costs.

Status / related

Found while reviewing #724, which keeps the fallback so behaviour is unchanged. Related: #696, #707.

Activity

  1. added
    accuracyAccuracy requirements, guarantees, and propagation
    bugSomething isn't working
    replacement-strategyASAP replacement candidates and physical strategies
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    accuracyAccuracy requirements, guarantees, and propagationbugSomething isn't workingreplacement-strategyASAP replacement candidates and physical strategies

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions