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

make backend as default parser #1140

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

yesoreyeram
Copy link
Collaborator

@yesoreyeram yesoreyeram commented Feb 3, 2025

Fixes https://github.com/grafana/oss-big-tent-squad/issues/32

Background

Currently when a new infinity query is added to the dashboard / explore page, the parser option is set to default/simple/frontend parser. This default parser is frontend parser. With this option, user will not be able to setup alerts, recorded queries, public dashboards or any other backend features. Since this is the default parser, users find it more annoying to migrate to backend parser at later stage to make it compatible with backend features.

This PR sets the backend parser as the default parser when adding a new query to the dashboard / explore page.

How to test

Before changes

  • git checkout main && yarn && yarn build && mage -v && docker compose up
  • Visit explore page with the default infinity datasource. You will see the parser set to default (frontend) as shown below and also the results
  • To ensure this is frontend parsing, visit the query inspector and you will see no data set in frames as shown below
image image

After changes

  • git checkout default-backend-parser && yarn && yarn build && mage -v && docker compose up
  • Visit explore page with the default infinity datasource. You will see the parser set to backend as shown below and also the results
  • To ensure this is backend parsing, visit the query inspector and you will see no data set in frames as shown below
image image

Migrating existing queries

Not only the new queries, this PR also migrates existing queries to use backend parser as default.

  • if the parser is already set, we should respect that
  • if the root_selector is already set, overriding the parser type will break the queries with frontend parsing. So we should leave as it is
  • if the query have columns defined, overriding the parser type will break the queries with frontend parsing. So we should leave as it is

Testing existing queries

@yesoreyeram yesoreyeram added this to the Version 3.0 milestone Feb 3, 2025
@@ -660,16 +660,6 @@ func TestInlineSources(t *testing.T) {
skipGoldenCheck bool
test func(t *testing.T, frame *data.Frame)
}{
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test is now removed. ( incorrect test )

@@ -194,6 +194,12 @@ func ApplyDefaultsToQuery(ctx context.Context, query Query, settings InfinitySet
query.Source = "url"
}
}
// if the parser is already set, we should respect that
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

main change in backend

@@ -13,6 +14,7 @@ import type { InfinityQuery } from './types';
*/
export const migrateQuery = (query: InfinityQuery): InfinityQuery => {
let newQuery: InfinityQuery = { ...query };
newQuery = setDefaultParserToBackend(newQuery);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

main change in frontend

@@ -28,128 +28,6 @@
"links": [],
"liveNow": true,
"panels": [
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cleanup. Not related to the PR.

@yesoreyeram yesoreyeram marked this pull request as ready for review February 5, 2025 11:51
@yesoreyeram yesoreyeram requested a review from a team as a code owner February 5, 2025 11:51
Copy link
Member

@ivanahuckova ivanahuckova left a comment

Choose a reason for hiding this comment

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

LGTM, left suggestion bellow.

pkg/models/query.go Show resolved Hide resolved
@yesoreyeram yesoreyeram mentioned this pull request Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants