Skip to content

Preserve distinct PromQL semantics for rate and irate in pre-ASAP IR #305

Description

@milindsrivastava1997

What happened

Two PromQL expressions with different derivative functions lower to byte-for-byte identical pre-ASAP IR:

rate(cumulative[5m])
irate(cumulative[5m])

The IR for both is:

{"Aggregate":{"child":{"TimeRange":{"child":{"Scan":{"predicates":[],"schema":{"closed":false,"columns":[{"dtype":"timestamp","name":"ts","nullable":false,"table":null},{"dtype":"float64","name":"value","nullable":false,"table":null}],"time_index":0,"unique_keys":[]},"source":{"TimeSeries":{"metric":"cumulative"}}}},"range":{"nanos":0,"secs":300}}},"having":null,"measures":[{"kind":"rate"}],"output_names":[""],"reduction":"PerEntity"}}

What I expected

The pre-ASAP IR should preserve the distinction between rate and irate, or explicitly document and justify a canonical representation that retains enough information for downstream execution to implement both semantics.

Steps to reproduce

  1. Run the PromQL corpus pre-ASAP dump command.
  2. Compare the per-query IR dumps for rate(cumulative[5m]) and irate(cumulative[5m]).
  3. Observe that both have Aggregate.measures[0].kind = "rate" and otherwise identical IR.

Additional context

PromQL defines different sampling behavior for rate and irate; collapsing both to AggIntent::Rate may make them execute identically. The corpus records are testdata queries 1757 and 1758.

Metadata

Metadata

Assignees

No one assigned

    Labels

    irPre-ASAP or post-ASAP intermediate representation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions