Skip to content

Commit f56b281

Browse files
committed
Fix @ modifier for subquery when split
Signed-off-by: 🌲 Harry 🌊 John 🏔 <[email protected]>
1 parent bb59466 commit f56b281

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
* [BUGFIX] Ring: update ring with new ip address when instance is lost, rejoins, but heartbeat is disabled. #6271
5858
* [BUGFIX] Ingester: Fix regression on usage of cortex_ingester_queried_chunks. #6398
5959
* [BUGFIX] Ingester: Fix possible race condition when `active series per LabelSet` is configured. #6409
60+
* [BUGFIX] Query Frontend: Fix @ modifier not being applied correctly on sub queries. #6450
6061

6162
## 1.18.1 2024-10-14
6263

pkg/querier/tripperware/queryrange/split_by_interval.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ func evaluateAtModifierFunction(query string, start, end int64) (string, error)
110110
}
111111
selector.StartOrEnd = 0
112112
}
113+
if selector, ok := n.(*parser.SubqueryExpr); ok {
114+
switch selector.StartOrEnd {
115+
case parser.START:
116+
selector.Timestamp = &start
117+
case parser.END:
118+
selector.Timestamp = &end
119+
}
120+
selector.StartOrEnd = 0
121+
}
113122
return nil
114123
})
115124
return expr.String(), err

pkg/querier/tripperware/queryrange/split_by_interval_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,14 @@ func Test_evaluateAtModifier(t *testing.T) {
377377
[2m:])
378378
[10m:])`,
379379
},
380+
{
381+
in: `irate(kube_pod_info{namespace="test"}[1h:1m] @ start())`,
382+
expected: `irate(kube_pod_info{namespace="test"}[1h:1m] @ 1546300.800)`,
383+
},
384+
{
385+
in: `irate(kube_pod_info{namespace="test"} @ end()[1h:1m] @ start())`,
386+
expected: `irate(kube_pod_info{namespace="test"} @ 1646300.800 [1h:1m] @ 1546300.800)`,
387+
},
380388
{
381389
// parse error: @ modifier must be preceded by an instant vector selector or range vector selector or a subquery
382390
in: "sum(http_requests_total[5m]) @ 10.001",

0 commit comments

Comments
 (0)