Skip to content

Commit

Permalink
Fix @ modifier for subquery when split
Browse files Browse the repository at this point in the history
Signed-off-by: 🌲 Harry 🌊 John 🏔 <[email protected]>
  • Loading branch information
harry671003 committed Dec 20, 2024
1 parent bb59466 commit f80b408
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/querier/tripperware/queryrange/split_by_interval.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ func evaluateAtModifierFunction(query string, start, end int64) (string, error)
}
selector.StartOrEnd = 0
}
if selector, ok := n.(*parser.SubqueryExpr); ok {
switch selector.StartOrEnd {
case parser.START:
selector.Timestamp = &start
case parser.END:
selector.Timestamp = &end
}
selector.StartOrEnd = 0
}
return nil
})
return expr.String(), err
Expand Down
4 changes: 4 additions & 0 deletions pkg/querier/tripperware/queryrange/split_by_interval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ func Test_evaluateAtModifier(t *testing.T) {
[2m:])
[10m:])`,
},
{
in: `irate(kube_pod_info{namespace="test"}[1h:1m] @ start())`,
expected: `irate(kube_pod_info{namespace="test"}[1h:1m] @ 1546300.800)`,
},
{
// parse error: @ modifier must be preceded by an instant vector selector or range vector selector or a subquery
in: "sum(http_requests_total[5m]) @ 10.001",
Expand Down

0 comments on commit f80b408

Please sign in to comment.