Skip to content

PromQL: topk/bottomk over bare instant vector produces unexpected Aggregate(Sum) #21

Description

@milindsrivastava1997

Summary

topk and bottomk applied to a bare instant vector (no range function) lower to Limit { Sort { Aggregate(Sum) { Scan } } }. The Aggregate(Sum) is unexpected — a bare instant vector is not a sum aggregation.

Reproduction

# P2 — topk over instant vector
topk(5, http_requests_total)

# P6 — bottomk over instant vector
bottomk(5, http_requests_total)

L3 output for P2:

Limit {
    n: 5,
    child: Sort {
        keys: [SortKey { ascending: false }],
        child: Aggregate {
            aggs: [Sum { col: None }],
            child: Scan { source: TimeSeries { metric: "http_requests_total" } }
        }
    }
}

Expected

A bare instant vector should not introduce a Sum aggregate. Expected output is Limit { Sort { Scan } } or similar without the wrapping aggregation.

Reproduce via example

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

Labels: P2, P6

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