Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send query plan to querier. #11246

Merged
merged 31 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b954bc2
start defining query plan
jeschkies Nov 14, 2023
32a4374
Pass parsed query
jeschkies Nov 16, 2023
4f3b9d8
Start fixing tests
jeschkies Nov 16, 2023
4f4bcc6
Parsed AST when not set.
jeschkies Nov 16, 2023
cbf3d1c
Wrap params
jeschkies Nov 16, 2023
9bb42ae
Rename params mapping
jeschkies Nov 16, 2023
945ecea
Embed shards as well
jeschkies Nov 16, 2023
80c6594
Pass downstreamer test
jeschkies Nov 16, 2023
424788d
Pass split by range
jeschkies Nov 16, 2023
648a134
Pass query
jeschkies Nov 16, 2023
7e7468b
Set plan in encode decode test
jeschkies Nov 16, 2023
3cc88cc
Merge remote-tracking branch 'grafana/main' into karsten/send-query-plan
jeschkies Nov 16, 2023
55d3169
Format protos
jeschkies Nov 17, 2023
f6a0715
Set plan if it's not set.
jeschkies Nov 20, 2023
56c5744
Merge remote-tracking branch 'grafana/main' into karsten/send-query-plan
jeschkies Nov 20, 2023
64d1e2e
Satisfy linter
jeschkies Nov 20, 2023
69a5ca2
Fix downstreamer test
jeschkies Nov 20, 2023
be2f785
Merge remote-tracking branch 'grafana/main' into karsten/send-query-plan
jeschkies Nov 20, 2023
7eb7056
Rename Query to QueryString
jeschkies Nov 21, 2023
e61f864
Merge remote-tracking branch 'grafana/main' into karsten/send-query-plan
jeschkies Nov 21, 2023
41bc4bb
Merge remote-tracking branch 'origin/karsten/send-query-plan' into ka…
jeschkies Nov 21, 2023
feefd4b
Use AST to determine type.
jeschkies Nov 21, 2023
1bb299a
Remove commented code with TODO
jeschkies Nov 21, 2023
1bacf24
Do no parse AST in split by range
jeschkies Nov 21, 2023
25a9b50
Calculate size with empty writer.
jeschkies Nov 21, 2023
01cfc39
Use append writer
jeschkies Nov 21, 2023
b371968
Remove obsolete test cases.
jeschkies Nov 21, 2023
3f44090
Merge remote-tracking branch 'grafana/main' into karsten/send-query-plan
jeschkies Nov 21, 2023
16b697a
Use GetExpression where applicable
jeschkies Nov 21, 2023
353e9c0
fix tests that panic because of missing Plan field
cstyan Nov 22, 2023
21b7c81
fix another test
cstyan Nov 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pkg/logcli/client/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (f *FileClient) Query(q string, limit int, t time.Time, direction logproto.

ctx = user.InjectOrgID(ctx, f.orgID)

params := logql.NewLiteralParams(
params, err := logql.NewLiteralParams(
q,
t, t,
0,
Expand All @@ -78,6 +78,9 @@ func (f *FileClient) Query(q string, limit int, t time.Time, direction logproto.
uint32(limit),
nil,
)
if err != nil {
return nil, err
dannykopping marked this conversation as resolved.
Show resolved Hide resolved
}

query := f.engine.Query(params)

Expand Down Expand Up @@ -106,7 +109,7 @@ func (f *FileClient) QueryRange(queryStr string, limit int, start, end time.Time

ctx = user.InjectOrgID(ctx, f.orgID)

params := logql.NewLiteralParams(
params, err := logql.NewLiteralParams(
queryStr,
start,
end,
Expand All @@ -116,6 +119,9 @@ func (f *FileClient) QueryRange(queryStr string, limit int, start, end time.Time
uint32(limit),
nil,
)
if err != nil {
return nil, err
}

query := f.engine.Query(params)

Expand Down
22 changes: 18 additions & 4 deletions pkg/logcli/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ func (q *Query) DoLocalQuery(out output.LogOutput, statistics bool, orgID string
var query logql.Query

if q.isInstant() {
query = eng.Query(logql.NewLiteralParams(
params, err := logql.NewLiteralParams(
q.QueryString,
q.Start,
q.Start,
Expand All @@ -460,9 +460,14 @@ func (q *Query) DoLocalQuery(out output.LogOutput, statistics bool, orgID string
q.resultsDirection(),
uint32(q.Limit),
nil,
))
)
if err != nil {
return err
}

query = eng.Query(params)
} else {
query = eng.Query(logql.NewLiteralParams(
params, err := logql.NewLiteralParams(
q.QueryString,
q.Start,
q.End,
Expand All @@ -471,7 +476,16 @@ func (q *Query) DoLocalQuery(out output.LogOutput, statistics bool, orgID string
q.resultsDirection(),
uint32(q.Limit),
nil,
))
)
if err != nil {
return err
}

query = eng.Query(params)
}

if err != nil {
return err
}

// execute the query
Expand Down
5 changes: 4 additions & 1 deletion pkg/logcli/query/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,10 @@ func (t *testQueryClient) Query(_ string, _ int, _ time.Time, _ logproto.Directi
func (t *testQueryClient) QueryRange(queryStr string, limit int, from, through time.Time, direction logproto.Direction, step, interval time.Duration, _ bool) (*loghttp.QueryResponse, error) {
ctx := user.InjectOrgID(context.Background(), "fake")

params := logql.NewLiteralParams(queryStr, from, through, step, interval, direction, uint32(limit), nil)
params, err := logql.NewLiteralParams(queryStr, from, through, step, interval, direction, uint32(limit), nil)
if err != nil {
return nil, err
}

v, err := t.engine.Query(params).Exec(ctx)
if err != nil {
Expand Down
50 changes: 24 additions & 26 deletions pkg/logproto/indexgateway.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pkg/logproto/indexgateway.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ syntax = "proto3";

package indexgatewaypb;

import "gogoproto/gogo.proto";
import "pkg/logproto/logproto.proto";

option go_package = "github.com/grafana/loki/pkg/logproto";
Expand Down
78 changes: 38 additions & 40 deletions pkg/logproto/sketch.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pkg/logproto/sketch.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ syntax = "proto3";

package logproto;

import "gogoproto/gogo.proto";
import "pkg/logproto/logproto.proto";

option go_package = "github.com/grafana/loki/pkg/logproto";
Expand Down
13 changes: 4 additions & 9 deletions pkg/logql/blocker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,10 @@ func TestEngine_ExecWithBlockedQueries(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
limits.blockedQueries = test.blocked

q := eng.Query(LiteralParams{
qs: test.q,
start: time.Unix(0, 0),
end: time.Unix(100000, 0),
step: 60 * time.Second,
direction: logproto.FORWARD,
limit: 1000,
})
_, err := q.Exec(user.InjectOrgID(context.Background(), "fake"))
params, err := NewLiteralParams(test.q, time.Unix(0, 0), time.Unix(100000, 0), 60*time.Second, 0, logproto.FORWARD, 1000, nil)
require.NoError(t, err)
q := eng.Query(params)
_, err = q.Exec(user.InjectOrgID(context.Background(), "fake"))

if test.expectedErr == nil {
require.NoError(t, err)
Expand Down
Loading