Repository navigation
promql: allow unquoted Unicode letters and dots behind a feature flag - #19683
Conversation
ab5677e to
e6395e3
Compare
|
Thanks for working on this @roidelapluie! We're trying it out on our fork and found one lexer regression with the flag enabled. A keyword directly followed by a decimal literal now gets absorbed into a dotted name: The first one is the nasty case. The query still parses, but it compares against a metric that doesn't exist and returns an empty result. We fixed it in for {
r := l.next()
// Not l.peek(): at EOF it zeroes l.width and breaks the backup below.
if r == '.' && int(l.pos) < len(l.input) && isDigit(rune(l.input[l.pos])) {
if _, ok := keyword(l.input[l.start : l.pos-1]); ok {
l.backup()
break
}
}
if !l.isNameContinue(r) && r != ':' {
l.backup()
break
}
}
We also moved the evaluation cases into |
|
Thank you, but I prefer to mark that as a "bug" of the current parser and have the new one threat bool.5 as a metric name. |
|
Ok. Fair. To me this felt more on the lines of: It was this way in Prometheus previously so we're not breaking. |
💯 Agreed, and it would really weird if anyone accidentally wrote their queries like that. |
7bd7b58 to
4502d4d
Compare
…ted names" This reverts commit 5bb274e. Upstream decided in prometheus#19683 that with unquoted UTF-8 names enabled, `bool.5` is a metric name and the old `bool 0.5` reading is a parser bug. Follow upstream so queries mean the same on the fork as they will upstream. Signed-off-by: Matthias Loibl <[email protected]>
4502d4d to
5f687df
Compare
ywwg
left a comment
There was a problem hiding this comment.
lgtm. The change makes sense, and the test cases seem to cover all the cases we are worried about.
Can you add one more case for specifying metric name inside and outside the braces? That should still be caught but just to make sure:
my.metric.name{"my.metric.name"}
Just a couple nits otherwise.
|
PTAL at roidelapluie#106 |
Signed-off-by: Julien Pivotto <[email protected]>
Add the evaluation cases for unquoted Unicode and dotted names to promqltest/testdata, so other PromQL implementations that run the built-in test files pick them up too. Enabling the parser option in TestParserOpts also runs every existing test file through the extended lexer, which catches regressions in existing syntax. Signed-off-by: Matthias Loibl <[email protected]>
Signed-off-by: Julien Pivotto <[email protected]>
206caba to
cbbef9f
Compare
|
Thanks @ywwg , I have fixed the comments and rebased |
Cherry-pick PR prometheus#19683 onto release-3.16. (cherry picked from commit e2e83df) Co-authored-by: Matthias Loibl <[email protected]> Signed-off-by: Julien Pivotto <[email protected]>
…#20162) Cherry-pick PR #19683 onto release-3.16. (cherry picked from commit e2e83df) Signed-off-by: Julien Pivotto <[email protected]> Co-authored-by: Matthias Loibl <[email protected]>
Which issue(s) does the PR fix:
Release notes for end users (ALL commits must be considered).
Reviewers should verify clarity and quality.