-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
Making durations and number literals the same #9138
base: main
Are you sure you want to change the base?
Conversation
a062c61
to
724ad46
Compare
Thank you. I expect that Beorn will want to look at this one, but you can expect some delays due to the summer period. |
According to your design doc, the following should work: |
I tried
I also left some comments on the design doc on questions I had. |
One thing I'm interested in is how this will affect the printing of PromQL expressions once they have been parsed. It would be sad if the input was:
...and we could only serialize it out again as:
Not sure if this is the plan already, but would it make sense to store the original tokens in the parsed AST somehow so that we can render them out again in a way that makes most sense to the user? |
That's a good point, but perhaps we can solve that later, once the main functionality is implemented. I think the comments above( #9138 (comment) , #9138 (comment) ) are real issues that need to be fixed. |
00f908b
to
20fdee0
Compare
thank you, will address 👍 |
3094b01
to
89c8d21
Compare
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 might come from my ignorance of parser internals, but wouldn't it be easier to just get rid of the DURATION type altogether and replace it with NUMBER everywhere? And then parse each number as a duration.
FYI, VictoriaMetrics supports using durations instead of numeric values and vice versa in MetricsQL. See, for example, how does |
We discussed this during our bug scrub. I think my point above is still valid and hasn't been addressed. @darshanime are you still up to working on this? This general topic comes up quite often, so we should finish this up one way or another. |
89c8d21
to
2e3d90a
Compare
9ecedb8
to
cf7a217
Compare
I skipped it originally because
There should be no such place now, and we should be able to use duration and number interchangeably...
Does this mean making a change in
Can we do this as part of a separate PR? |
Excellent. Thank you very much. I'll have a detailed look in the coming week, but it seems we are now where we want to be.
The CHANGELOG.md update is only created during the release, but there is "real" documentation for PromQL. Once this change is declared stable, we have to go through the whole body of PromQL documentation and make sure that numbers and durations are the same everywhere. For now, this will be an experimental change (see Julius's comment), so we only have to extend the definition of float literals and durations by something like "As of version 2.52, durations can also be represented by float values, implying the number of seconds. This is an experimental feature and might still change." or "As of version 2.52, float values can also be represented using the syntax of durations, where the duration literal is converted into a float value corresponding to the number of seconds the duration literal represents." (I guess more wordsmithing should apply here, just trying to point in the right direction. Also, an example might be good.) The file to change is https://github.com/prometheus/prometheus/blob/main/docs/querying/basics.md .
Technically yes, but we should definitely minimize the duration of having inconsistent version of the UI code and the PromQL implementation in the backend in the main branch. If you plan to work on the UI code yourself, it would indeed be best to add commits to this PR (but having UI code and backend code in different commits would be desired). If you cannot work on the UI code, we should ask our React experts for help. If one of them works on this, they could create a separate PR, but we should merge both PRs at about the same time. So the question is: Do you plan to work on the UI code yourself? |
Yes please, that would be great! I will update the documentation, tfr! |
Okay so to address this, changes need to be made to Now while I have a broad idea of what to do, I'm unfamiliar with yacc and .grammar and they're a blocker for me atm. But so far the steps I can see are:
Again, updating the grammar file itself is a hurdle for me and its where I'd need help. I can then work on adding tests and updating |
The final outcome has to be that @Nexucis and @darshanime can probably help better here than I. |
Yeah, @Nexucis is the most knowledgeable when it comes to the grammar-related functionality, especially the completion and linting. But what just occurred to me: For autocompletion, we will not want to treat numbers and durations the same in all places. We currently autocomplete the unit suffix for durations, but it would not make sense to do that in places where only a normal number would make sense. So I guess there'd need to be some higher-level logic that checks the context in which the |
Not sure if it is worth the effort to distinguish those cases.
|
On the other hand, it's probably fine to only do the autocomplete where there is a duration for sure. You can still type things that the autocomplete didn't suggest, so no harm done if the autocomplete is a bit too restrictive. |
@Maniktherana I assume you still need some answers for the parser part. @Nexucis could you help out @Maniktherana ? He spelled out his plan above and it appears he would like to know if that's the right approach. @darshanime as discussed, we still need an update to the docs in this PR. |
Signed-off-by: darshanime <deathbullet@gmail.com>
Signed-off-by: darshanime <deathbullet@gmail.com>
Signed-off-by: darshanime <deathbullet@gmail.com>
7521970
to
ee5f277
Compare
Hello, Sorry for the time it took me to reply.
And then replace I don't think we need to update
It's possible we won't be able to autocomplete duration everywhere it is today. Let see.
|
Probably we can do that in a second PR. It's indeed possible to have this kind of logic as we already do that for some use cases. I would advise to just do it later to reduce the number of changes in a single PR and also because doing this kind of logic can break the whole code if you don't do it conscientiously |
@Maniktherana let me know if you need more input from me |
I'm tracking, I'm currently out of town however without my laptop. Will be back in a couple of days. |
Thank you very much @Maniktherana and @Nexucis . Looking forward to the PR for the UI. @darshanime thank for your patience with this. I'm currently looking at the docs addition in this PR. |
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.
Some wordsmithing for the comments. An also an actual correction because 0.01 != 1ms.
Signed-off-by: darshanime <deathbullet@gmail.com>
ee5f277
to
1cbae54
Compare
Signed-off-by: darshanime <deathbullet@gmail.com>
@beorn7, addressed. tfr! |
Approved! Thank you very much. However, let's hold back merging for now until @Maniktherana is more or less done with the UI updates, so that we don't have an inconsistent state in main. |
Here an update after a bit back and forth: The frontend changes we need here are mostly in the grammar part, so it's not really React specific, and @Maniktherana , who wanted to give it a spin, feels way outside of his comfort zone. We tried to get @Nexucis work on it, but he won't have time anytime soon. Maybe @juliusv can help out here? On the other hand, maybe the changes aren't that different from the one in this PR, and @darshanime might be able to do it after all, given that @Nexucis has already given some guidance above. We could also try to find some random contributor knowledgeable with the lezer-promql stuff. The last resort is that I do it myself. As this is not exactly my area of expertise, I'll need some time to execute it, and I have also so many things queued up that I have to get done before even getting to this. |
About this: @Nexucis and I both tried out the suggestions and that doesn't seem to be the solution. The output I was getting when trying out the following:
The output I was getting is:
|
Design doc: https://docs.google.com/document/d/1LaZfknXuuRWGtQSbULoMtclQhuLUMrdwg15wMvoBvCQ/edit#
Signed-off-by: darshanime deathbullet@gmail.com