Skip to content

Commit

Permalink
split interval middleware sends query when start equals false (#5714)
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <[email protected]>

Signed-off-by: Ben Ye <[email protected]>
  • Loading branch information
yeya24 authored Sep 26, 2022
1 parent a31e4c5 commit 1c18ef4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/cortex/querier/queryrange/split_by_interval.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ func (s splitByInterval) Do(ctx context.Context, r Request) (Response, error) {
}

func splitQuery(r Request, interval time.Duration) ([]Request, error) {
// If Start == end we should just run the original request.
if r.GetStart() == r.GetEnd() {
return []Request{r}, nil
}

// Replace @ modifier function to their respective constant values in the query.
// This way subqueries will be evaluated at the same time as the parent query.
query, err := evaluateAtModifierFunction(r.GetQuery(), r.GetStart(), r.GetEnd())
Expand Down
17 changes: 17 additions & 0 deletions internal/cortex/querier/queryrange/split_by_interval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ func TestSplitQuery(t *testing.T) {
},
interval: day,
},
{
input: &PrometheusRequest{
Start: 60 * 60 * seconds,
End: 60 * 60 * seconds,
Step: 15 * seconds,
Query: "foo",
},
expected: []Request{
&PrometheusRequest{
Start: 60 * 60 * seconds,
End: 60 * 60 * seconds,
Step: 15 * seconds,
Query: "foo",
},
},
interval: day,
},
{
input: &PrometheusRequest{
Start: 0,
Expand Down

0 comments on commit 1c18ef4

Please sign in to comment.