Skip to content

PromQL: topk over cross-series aggregation (e.g. sum by) is unsupported #23

Closed

Description

@milindsrivastava1997

Summary

topk applied to the output of a cross-series aggregation operator (e.g. sum by (...)) fails with an unsupported feature error. This is a valid and common PromQL pattern.

Reproduction

# P5 — topk over sum-by aggregation
topk(5, sum by (service) (http_requests_total))

Error:

ERR: unsupported feature: aggregate argument: Discriminant(0)

Expected

Should lower to Limit { Sort { Aggregate(Sum, by:[service]) { Scan } } } — the topk becomes a Sort+Limit over the inner aggregation result.

Reproduce via example

cargo run -p asap-control-lower --example topk_ir

Labels: P5

Activity

  1. zzylol commented on Jul 2, 2026

    @zzylol
    Contributor

    Verified fixed on latest main (via PRs #28/#29, which added nested-aggregate lowering + ColumnRef::SampleValue resolution to the sole numeric column).

    topk(5, sum by (service) (http_requests_total)) (P5) now lowers to exactly the Expected shape:

    Limit { n:5, Sort { keys:[col1 desc] } → Aggregate { by:[2 (service)], aggs:[Sum] } → Scan }
    

    No more unsupported feature: aggregate argument. Reproduced via cargo run -p asap-control-lower --example topk_ir. Closing.

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