diff --git a/promql/parser/ast.go b/promql/parser/ast.go index 3c5858ce40..64b4a2ec6a 100644 --- a/promql/parser/ast.go +++ b/promql/parser/ast.go @@ -198,11 +198,12 @@ type VectorSelector struct { // Offset is the offset used during the query execution // which is calculated using the original offset, at modifier time, // eval time, and subquery offsets in the AST tree. + SkipHistogramBuckets bool // Set when decoding native histogram buckets is not needed for query evaluation. Offset time.Duration Timestamp *int64 - SkipHistogramBuckets bool // Set when decoding native histogram buckets is not needed for query evaluation. StartOrEnd ItemType // Set when @ is used with start() or end() LabelMatchers []*labels.Matcher + LookbackDelta time.Duration // The unexpanded seriesSet populated at query preparation time. UnexpandedSeriesSet storage.SeriesSet @@ -215,6 +216,14 @@ type VectorSelector struct { PosRange posrange.PositionRange } +func (m *VectorSelector) GetLookbackDelta(d time.Duration) time.Duration { + if m.LookbackDelta > 0 { + return m.LookbackDelta + } + + return d +} + // TestStmt is an internal helper statement that allows execution // of an arbitrary function during handling. It is used to test the Engine. type TestStmt func(context.Context) error