Skip to content

Port duration-arithmetic expressions in range / offset / @ positions (DurationExpr) #3

Description

@zzylol

Summary

Arithmetic in duration positions parse-fails: changes(http_requests[26m+4m])unexpected character inside brackets: '+'; metric offset (2*2), count_over_time(m[step()+1ms]), sum_over_time(m[29s+1s:5s+5s]) likewise. Prometheus recently generalized durations to full expressions.

Current state (verified)

No DurationExpr in src/parser/ast.rs on the asap branch or GreptimeTeam upstream main (grep count 0). The lexer errors on any non-digit/unit character inside [...].

Note: step, range, min_of, max_of are already in the function table (added by c51beaf), but they only appear inside duration expressions, so they cannot be reached until this lands.

Work

  • A DurationExpr AST node (literal duration, step(), range(), and + - * / % ^ over them).
  • Lexer: allow arithmetic tokens inside range / offset / @ duration contexts.
  • Grammar productions for duration expressions in matrix_selector, subquery_expr, offset, @.

Corpus impact

51 rejections.

Constraint

All changes on the asap branch; no upstream operations.

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions