Skip to content

feat(planner): support nested temporal aggregation pipelines #772

Open

Description

@milindsrivastava1997

Goal

Support native PromQL execution for nested aggregation pipelines whose innermost expression is a temporal function over a range selector.

Motivation

The differential compliance suite can currently cover one temporal function plus one outer aggregation, but the planner rejects a second aggregation layer such as topk(3, sum by (job) (rate(data[5m]))). The compliance runner disables forwarding for unsupported queries, so those expressions cannot be exercised as native Prometheus-vs-ASAPQuery comparisons.

Scope

  • Support nested aggregation pipelines with a temporal anchor, including rate, increase, sum_over_time, count_over_time, avg_over_time, min_over_time, and max_over_time where their statistics can be represented correctly.
  • Support inner aggregation grouping with no grouping, by (...), and without (...).
  • Support outer reducers (sum, count, avg, min, max) and topk where their composition is semantically valid.
  • Preserve PromQL instant/range semantics and TopK ordering: instant TopK values are descending within each group; range matrices have no ordering requirement.

Acceptance criteria

  • The planner generates native configurations for representative nested temporal queries such as topk(3, sum by (job) (rate(data[5m]))) and avg(sum by (job, instance) (rate(data[5m]))).
  • Native /query and /query_range results match Prometheus at shared evaluation times.
  • Grouped TopK preserves within-bucket order for instant queries without imposing a bucket order.
  • Unsupported compositions fail explicitly rather than silently falling back or dropping an aggregation stage.

Follow-up testing

Once this capability exists, add the full temporal-anchor × inner grouping × outer-reducer compliance matrix.

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