From db0a1bc30f05b6ef1936171e541269df17499e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Tue, 12 Aug 2025 15:22:30 +0200 Subject: [PATCH] Remove `sqlDatasourceDatabaseSelection` feature toggle (#109391) * Remove `sqlDatasourceDatabaseSelection` feature toggle * Update e2e tests --- .../datasources/mysql/query-editor/_index.md | 2 +- .../feature-toggles/index.md | 1 - .../plugin-e2e/mysql/mocks/mysql.mocks.ts | 2 +- .../mysql/visual-query-builder.spec.ts | 14 ++++---- .../src/types/featureToggles.gen.ts | 4 --- .../src/components/DatasetSelector.tsx | 33 +++---------------- .../QueryEditorFeatureFlag.utils.ts | 5 --- .../src/components/QueryHeader.tsx | 6 ---- .../src/components/SqlComponents.test.tsx | 10 ------ .../src/datasource/SqlDatasource.ts | 12 +++---- pkg/services/featuremgmt/registry.go | 8 ----- pkg/services/featuremgmt/toggles_gen.csv | 1 - pkg/services/featuremgmt/toggles_gen.go | 4 --- pkg/services/featuremgmt/toggles_gen.json | 3 +- 14 files changed, 19 insertions(+), 86 deletions(-) delete mode 100644 packages/grafana-sql/src/components/QueryEditorFeatureFlag.utils.ts diff --git a/docs/sources/datasources/mysql/query-editor/_index.md b/docs/sources/datasources/mysql/query-editor/_index.md index b34bcf65935..5139a04d2f3 100644 --- a/docs/sources/datasources/mysql/query-editor/_index.md +++ b/docs/sources/datasources/mysql/query-editor/_index.md @@ -70,7 +70,7 @@ Grafana’s query editors are unique for each data source. For general informati The MySQL query editor is located on the [Explore page](ref:explore). You can also access the MySQL query editor from a dashboard panel. Click the ellipsis in the upper right of the panel and select **Edit**. {{< admonition type="note" >}} -If a default database is configured in the **Data Source Configuration page**, or via a provisioning configuration file, users will be restricted to querying only that pre-configured database. This feature is behind a feature flag and is available once you enable `sqlDatasourceDatabaseSelection`. +If a default database is configured in the **Data Source Configuration page**, or via a provisioning configuration file, users will be restricted to querying only that pre-configured database. {{< /admonition >}} ## MySQL query editor components diff --git a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md index e66178703ff..c5b1d0d05d1 100644 --- a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md +++ b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @@ -90,7 +90,6 @@ Most [generally available](https://grafana.com/docs/release-life-cycle/#general- | `refactorVariablesTimeRange` | Refactor time range variables flow to reduce number of API calls made when query variables are chained | | `faroDatasourceSelector` | Enable the data source selector within the Frontend Apps section of the Frontend Observability | | `enableDatagridEditing` | Enables the edit functionality in the datagrid panel | -| `sqlDatasourceDatabaseSelection` | Enables previous SQL data source dataset dropdown behavior | | `reportingRetries` | Enables rendering retries for the reporting feature | | `externalServiceAccounts` | Automatic service account and token setup for plugins | | `cloudWatchBatchQueries` | Runs CloudWatch metrics queries as separate batches | diff --git a/e2e-playwright/plugin-e2e/mysql/mocks/mysql.mocks.ts b/e2e-playwright/plugin-e2e/mysql/mocks/mysql.mocks.ts index 63718c6d1a4..0b235c01a31 100644 --- a/e2e-playwright/plugin-e2e/mysql/mocks/mysql.mocks.ts +++ b/e2e-playwright/plugin-e2e/mysql/mocks/mysql.mocks.ts @@ -64,7 +64,7 @@ export const datasetResponse = { }, fields: [{ name: 'TABLE_SCHEMA', type: 'string', typeInfo: { frame: 'string', nullable: true } }], }, - data: { values: [['DataMaker', 'mysql', 'performance_schema', 'sys']] }, + data: { values: [['grafana', 'mysql', 'performance_schema', 'sys']] }, }, ], }, diff --git a/e2e-playwright/plugin-e2e/mysql/visual-query-builder.spec.ts b/e2e-playwright/plugin-e2e/mysql/visual-query-builder.spec.ts index 9cf6c580927..e54c8749300 100644 --- a/e2e-playwright/plugin-e2e/mysql/visual-query-builder.spec.ts +++ b/e2e-playwright/plugin-e2e/mysql/visual-query-builder.spec.ts @@ -48,7 +48,7 @@ test.describe( await expect( explorePage.getByGrafanaSelector(selectors.components.CodeEditor.container).getByRole('textbox') ).toHaveValue( - `SELECT\n $__timeGroupAlias(createdAt, $__interval),\n AVG(\`bigint\`)\nFROM\n DataMaker.normalTable\nLIMIT\n 50` + `SELECT\n $__timeGroupAlias(createdAt, $__interval),\n AVG(\`bigint\`)\nFROM\n grafana.normalTable\nLIMIT\n 50` ); }); @@ -83,9 +83,7 @@ test.describe( // Validate that the timeFilter macro was added await expect( explorePage.getByGrafanaSelector(selectors.components.CodeEditor.container).getByRole('textbox') - ).toHaveValue( - `SELECT\n createdAt\nFROM\n DataMaker.normalTable\nWHERE\n $__timeFilter(createdAt)\nLIMIT\n 50` - ); + ).toHaveValue(`SELECT\n createdAt\nFROM\n grafana.normalTable\nWHERE\n $__timeFilter(createdAt)\nLIMIT\n 50`); // Validate that the timeFilter macro was removed when changed to equals operator await explorePage.getByGrafanaSelector(selectors.components.SQLQueryEditor.filterOperator).click(); @@ -96,7 +94,7 @@ test.describe( await expect( explorePage.getByGrafanaSelector(selectors.components.CodeEditor.container).getByRole('textbox') - ).not.toHaveValue(`SELECT\n createdAt\nFROM\n DataMaker.normalTable\nWHERE\n createdAt = NULL\nLIMIT\n 50`); + ).not.toHaveValue(`SELECT\n createdAt\nFROM\n grafana.normalTable\nWHERE\n createdAt = NULL\nLIMIT\n 50`); }); test('visual query builder should not crash when filter is set to select_any_in', async ({ explorePage, page }) => { @@ -114,7 +112,7 @@ test.describe( uid: 'P4FDCC188E688367F', }, format: 'table', - rawSql: "SELECT * FROM DataMaker.normalTable WHERE name IN ('a') LIMIT 50 ", + rawSql: "SELECT * FROM grafana.normalTable WHERE name IN ('a') LIMIT 50 ", editorMode: 'builder', sql: { columns: [ @@ -157,7 +155,7 @@ test.describe( }, whereString: "name IN ('a')", }, - dataset: 'DataMaker', + dataset: 'grafana', table: 'normalTable', }, ], @@ -170,7 +168,7 @@ test.describe( // Validate the query await expect( explorePage.getByGrafanaSelector(selectors.components.CodeEditor.container).getByRole('textbox') - ).toHaveValue(`SELECT\n *\nFROM\n DataMaker.normalTable\nWHERE\n name IN ('a')\nLIMIT\n 50`); + ).toHaveValue(`SELECT\n *\nFROM\n grafana.normalTable\nWHERE\n name IN ('a')\nLIMIT\n 50`); }); } ); diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index ab2b61ba179..9e53b6cb08b 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -161,10 +161,6 @@ export interface FeatureToggles { */ pluginsFrontendSandbox?: boolean; /** - * Enables previous SQL data source dataset dropdown behavior - */ - sqlDatasourceDatabaseSelection?: boolean; - /** * Enables writing multiple items from a single query within Recorded Queries * @default true */ diff --git a/packages/grafana-sql/src/components/DatasetSelector.tsx b/packages/grafana-sql/src/components/DatasetSelector.tsx index 6059d7efe43..f7324005e03 100644 --- a/packages/grafana-sql/src/components/DatasetSelector.tsx +++ b/packages/grafana-sql/src/components/DatasetSelector.tsx @@ -1,4 +1,3 @@ -import { useEffect } from 'react'; import { useAsync } from 'react-use'; import { SelectableValue } from '@grafana/data'; @@ -7,8 +6,6 @@ import { Select } from '@grafana/ui'; import { DB, ResourceSelectorProps, SQLDialect, toOption } from '../types'; -import { isSqlDatasourceDatabaseSelectionFeatureFlagEnabled } from './QueryEditorFeatureFlag.utils'; - export interface DatasetSelectorProps extends ResourceSelectorProps { db: DB; dataset: string | undefined; @@ -37,13 +34,11 @@ export const DatasetSelector = ({ const hasPreconfigCondition = !!preconfiguredDataset || dialect === 'postgres'; const state = useAsync(async () => { - if (isSqlDatasourceDatabaseSelectionFeatureFlagEnabled()) { - // If a default database is already configured for a MSSQL or MySQL data source, OR the data source is Postgres, no need to fetch other databases. - if (hasPreconfigCondition) { - // Set the current database to the preconfigured database. - onChange(toOption(preconfiguredDataset)); - return [toOption(preconfiguredDataset)]; - } + // If a default database is already configured for a MSSQL or MySQL data source, OR the data source is Postgres, no need to fetch other databases. + if (hasPreconfigCondition) { + // Set the current database to the preconfigured database. + onChange(toOption(preconfiguredDataset)); + return [toOption(preconfiguredDataset)]; } // If there is no preconfigured database, but there is a selected dataset, set the current database to the selected dataset. @@ -56,24 +51,6 @@ export const DatasetSelector = ({ return datasets.map(toOption); }, []); - useEffect(() => { - if (!isSqlDatasourceDatabaseSelectionFeatureFlagEnabled()) { - // Set default dataset when values are fetched - if (!dataset) { - if (state.value && state.value[0]) { - onChange(state.value[0]); - } - } else { - if (state.value && state.value.find((v) => v.value === dataset) === undefined) { - // if value is set and newly fetched values does not contain selected value - if (state.value.length > 0) { - onChange(state.value[0]); - } - } - } - } - }, [state.value, onChange, dataset]); - return (