-
Notifications
You must be signed in to change notification settings - Fork 454
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
[query] Fix bug with parsing Graphite find query #1676
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1676 +/- ##
========================================
- Coverage 71.8% 71.8% -0.1%
========================================
Files 968 968
Lines 81169 81177 +8
========================================
- Hits 58345 58339 -6
- Misses 18990 19002 +12
- Partials 3834 3836 +2
Continue to review full report at Codecov.
|
Ah nice, I like the approach of using explicit match types too. Good stuff! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -38,6 +38,9 @@ enum MatcherType { | |||
// matcher name rather than value | |||
EXISTS = 4; | |||
NOTEXISTS = 5; | |||
// ALL superceeds other matcher types | |||
// and does no filtering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
's
@@ -45,6 +45,20 @@ func TestConvertMetricPartToMatcher(t *testing.T) { | |||
} | |||
} | |||
|
|||
func TestConverWildcardToMatcher(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spelling: Convert
@@ -45,6 +45,20 @@ func TestConvertMetricPartToMatcher(t *testing.T) { | |||
} | |||
} | |||
|
|||
func TestConverWildcardToMatcher(t *testing.T) { | |||
metric := "*" | |||
for i := 0; i < 100; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of a weird test -- why not just run this once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to ensure that the metric name is also converted to expected (i.e. __g100__
) as well
@@ -38,6 +38,10 @@ func (m MatchType) String() string { | |||
return "=~" | |||
case MatchNotRegexp: | |||
return "!~" | |||
case MatchField: | |||
return "-" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my understanding, how did you come up with these mappings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made 'em up :p
It's not really a "standard" matcher type, and the only thing this affects is the String()
method on MatchTypes so we should be fine here
@@ -192,6 +192,17 @@ func matcherToQuery(matcher models.Matcher) (idx.Query, error) { | |||
} | |||
return query, nil | |||
|
|||
case models.MatchNotField: | |||
negate = true | |||
fallthrough |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - good use of fallthrough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What this PR does / why we need it:
This fixes an issue with parsing graphite find queries. Previously,
foo.*
would get split up intofoo
, and*
, which would go through a graphite globber and become[^\.]*
, which would then not get correctly identified as aNewFieldQuery
in the storage/index (this would convert regex values looking for.*
only to aNewFieldQuery
.This PR adds
MatchField
andMatchNotField
match types, and explicitly makes use of them in graphite queries, avoiding relying on implicit conversion in the storage layer.Does this PR introduce a user-facing and/or backwards incompatible change?: