Skip to content

Commit

Permalink
Set query plan when copying LokiRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
jeschkies committed Nov 22, 2023
1 parent e28f7f3 commit 21ccc63
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/querier/queryrange/split_by_interval.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ func splitByTime(req queryrangebase.Request, interval time.Duration) ([]queryran
Path: r.Path,
StartTs: start,
EndTs: end,
Plan: r.Plan,
})
})
case *LokiSeriesRequest:
Expand Down
12 changes: 10 additions & 2 deletions pkg/querier/queryrange/split_by_interval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import (

"github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql/syntax"
"github.com/grafana/loki/pkg/logqlmodel/stats"
"github.com/grafana/loki/pkg/querier/plan"
"github.com/grafana/loki/pkg/querier/queryrange/queryrangebase"
"github.com/grafana/loki/pkg/storage/config"
)
Expand Down Expand Up @@ -57,25 +59,31 @@ var testSchemasTSDB = func() []config.PeriodConfig {
func Test_splitQuery(t *testing.T) {
buildLokiRequest := func(start, end time.Time) queryrangebase.Request {
return &LokiRequest{
Query: "foo",
Query: `{app="foo"}`,
Limit: 1,
Step: 2,
StartTs: start,
EndTs: end,
Direction: logproto.BACKWARD,
Path: "/path",
Plan: &plan.QueryPlan{
AST: syntax.MustParseExpr(`{app="foo"}`),
},
}
}

buildLokiRequestWithInterval := func(start, end time.Time) queryrangebase.Request {
return &LokiRequest{
Query: "foo",
Query: `{app="foo"}`,
Limit: 1,
Interval: 2,
StartTs: start,
EndTs: end,
Direction: logproto.BACKWARD,
Path: "/path",
Plan: &plan.QueryPlan{
AST: syntax.MustParseExpr(`{app="foo"}`),
},
}
}

Expand Down

0 comments on commit 21ccc63

Please sign in to comment.