-
Notifications
You must be signed in to change notification settings - Fork 17
Update visual query build from grafana upstream #318
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
base: main
Are you sure you want to change the base?
Update visual query build from grafana upstream #318
Conversation
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.
Pull Request Overview
This PR updates the visual query builder’s source by aligning it more closely with upstream Grafana PromQL code while incorporating updates from PromQL lezer grammar. Key changes include adding the ErrorId constant, modifying error handling and label extraction in parsing, updating function argument processing for operations, and updating dependency versions in package.json.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/querybuilder/shared/parsingUtils.ts | Adds a new constant ErrorId with explanatory comment |
src/querybuilder/parsing.ts | Updates parsing logic including error node detection, label extraction, function argument handling, and operation order |
src/configuration/ConfigEditor.tsx | Adjusts imports in configuration editor by adding FeatureToggles and removing an unused import |
package.json | Upgrades @lezer/common dependency version |
Comments suppressed due to low confidence (2)
src/querybuilder/parsing.ts:223
- The variable 'body' is used in this conditional but is not defined in the surrounding context. Consider using 'callArgs' consistently or defining 'body' if that is the intended variable.
if (getString(expr, body) === '([' + interval + '])') {
src/querybuilder/parsing.ts:231
- The switch from unshifting to pushing operations in the query builder changes the order of operations. Verify that this change is intentional and that it maintains the expected natural order in the visual query editor.
visQuery.operations.push(op);
FYI: We already have lezer-metricsql located in |
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.
Thanks for the pull request! LGTM!
f0b887e
to
ed1b0cc
Compare
ed1b0cc
to
76f71b2
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.
Pull Request Overview
This PR updates the visual query builder by aligning parts of its source code more closely with the upstream Grafana implementation and updating dependencies. Key changes include adding and reusing an exported error node identifier, refactoring context usage (switching to an InternalContext with a function call stack), and minor adjustments in parsing logic and regex for label values.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/querybuilder/shared/parsingUtils.ts | Exports a new ErrorId constant for error node identification. |
src/querybuilder/parsing.ts | Refactors context type to InternalContext, adds function call stack management, revises label parsing and binary operation insertion logic, and adjusts error reporting. |
src/configuration/ConfigEditor.tsx | Updates import statements by removing unused components and adding FeatureToggles. |
package.json | Upgrades the @lezer/common dependency version. |
Comments suppressed due to low confidence (1)
src/querybuilder/parsing.ts:372
- The logic for computing the insertion index using functionCallStack is not immediately clear; please add an explanatory comment to clarify the intended ordering of binary operations.
let idx = visQuery.operations.length;
Fixes #317
Bringing sources closer to Prometheus Visual Query Builder code
Copied relevant tests
PromQL lezer grammar has also been updated recently, so maybe a good next step should be updating metricsql lezer grammar, this way it will be possible to bring visual query builder's sources even closer to grafana promql's