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

feat: support for flux cardinality query #22441

Merged
merged 7 commits into from
Sep 13, 2021
Merged

Conversation

williamhbaker
Copy link
Contributor

Closes #21513

This PR adds support for the flux cardinality query.

Copy link
Contributor

@danxmoran danxmoran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nitpicks, but overall LGTM! The integration tests really help.

Would it make sense to add a perf-test case for this query vs. InfluxQL?


buf, err := http.SimpleQuery(l.URL(), query, l.Org.Name, l.Auth.Token)
if err != nil {
t.Fatalf("unexpected error querying server: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use require.NoError instead of t.Fatal in these spots? The test is mixing both styles now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated! Was some cruft from copy/paste of previous tests. Using require makes the error messages more readable as well IMO, so that's a nice bonus.

buf, err := http.SimpleQuery(l.URL(), query, l.Org.Name, l.Auth.Token)
if err != nil {
t.Fatalf("unexpected error querying server: %v", err)
} else if diff := cmp.Diff(string(buf), exp); diff != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preference would be for require.Equal instead of cmp.Diff + t.Fatal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated; see above.

if err != nil {
t.Fatalf("unexpected error querying server: %v", err)
} else if diff := cmp.Diff(string(buf), tt.exp); diff != "" {
t.Fatal(diff)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preference for require here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated; see above.

}

if found := reads.HasFieldValueKey(expr); found {
return nil, errors.New("field values unsupported")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this error get wrapped up with more prefixes before being shown to the user? If not, I think it'd be good to add a little more detail (i.e. filtering on field values is not supported in cardinality predicates)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't really get wrapped in anything helpful so I updated the error message as you suggest.

No matter what, it currently gives the rather unhelpful Error: failed to execute query: 500 Internal Server Error: An internal error has occurred message, but this should be improved by #22448

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not anymore - now it's just a pointer to the logs again.

Ideally at some point this error would translate to something user-visible. (i.e. would be translated to an influxdb.Error)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, #22448 will at least log the error message though, so that's something.

v1/services/storage/store.go Show resolved Hide resolved
}

// shard is entirely within the specified time range
if sg.StartTime.After(time.Unix(0, start)) && sg.EndTime.Before(time.Unix(0, end)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are After and Before inclusive? Or exclusive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exclusive! Nice catch. I updated the code to check for shards being within the range inclusive and added some test cases for this method.

@williamhbaker
Copy link
Contributor Author

Would it make sense to add a perf-test case for this query vs. InfluxQL?

I think that's a good idea - at least for the cases where the two can perform an equivalent query. Flux can do time ranges and predicates, which InfluxQL cannot, and those are obviously going to be slower queries. But for the fast path, a benchmark would be good. I've created an issue for that here: #22455

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flux influxdb.cardinality fails: influxdb provider requires a host to be specified
3 participants