Skip to content

Support multi-measure per-entity aggregate schemas #409

Description

@milindsrivastava1997

What to build

Allow a Reduction::PerEntity aggregate to represent more than one aggregate measure while preserving the label set, timestamp, and a well-defined output schema for every measure.

Today, per-entity range reductions are structurally limited to one measure. This blocks algebraically valid rewrites such as avg_over_time(x) → sum_over_time(x) / count_over_time(x), tracked by #410.

Current schema derivation encodes the limitation:

Reduction::PerEntity => {
    debug_assert_eq!(measures.len(), 1, "a per-entity reduction is single-aggregate");
    return Ok(per_series_reduction_schema(in_schema, &measures[0]));
}

and the per-series path replaces the one conventional sample-value column:

let mut columns = input.columns.clone();
columns[vi] = out; // `out.name` is forced to "value"

The resulting schema cannot carry both a per-series sum and count. Define and implement the smallest compatible multi-measure schema contract, including naming and type behavior, so downstream lowering and binary operations can safely consume it.

Acceptance criteria

  • A PerEntity aggregate with multiple measures has a deterministic, validated output schema that preserves timestamp and labels and exposes every measure.
  • The single-measure PromQL range-function schema remains unchanged: its output sample column is named value and is Float64.
  • Schema derivation, resolution, and physical lowering either support the new shape end-to-end or reject unsupported forms with a clear error; they must not silently drop measures.
  • Focused tests cover a two-measure per-entity aggregate and protect existing single-measure range-function behavior.

Blocked by

None — can start immediately.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions