Andrew Hall 3bda9a3396
promql: allow timestamp() to be wrapped as a step invariant depending on arguments (#17313)
Some timestamp functions can be safely wrapped as a step invariant.
Then once we do that we never need to check or unwrap at evaluation time.

For instance; `timestamp(metric @ 1)` is step invariant, whereas
`timestamp(abs(metric @ 1))` is not.

Currently all `timestamp` `*parser.Call` are excluded from being
considered step invariant since it is listed in the
`AtModifierUnsafeFunctions` map.

This PR adds an extra check for timestamp functions which consider
the arguments, and if the argument is a simple VectorSelector then
the entire `*parser.Call` can be safely wrapped as a step invariant.

Signed-off-by: Andrew Hall <andrew.hall@grafana.com>
Co-authored-by: Bryan Boreham <bjboreham@gmail.com>
2026-03-02 12:01:14 +00:00
..