Skip to content

Commit 8469781

Browse files
Remove the athenaAsyncQuerySupport feature toggle and styling improvements (#316)
--------- Co-authored-by: Kevin Yu <[email protected]>
1 parent 330b7ec commit 8469781

File tree

10 files changed

+39
-72
lines changed

10 files changed

+39
-72
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 2.14.0
4+
- Remove the athenaAsyncQuerySupport feature toggle + styling improvements in [#316](https://github.com/grafana/athena-datasource/pull/316)
5+
36
## 2.13.6
47
- Fix: Rebuild the datasource when settings change in [#314](https://github.com/grafana/athena-datasource/pull/314)
58
- Bring in [security fixes in go 1.21.8](https://groups.google.com/g/golang-announce/c/5pwGVUPoMbg)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ The backend driver is based on the implementation of [uber/athenadriver](https:/
288288

289289
## Async Query Data Support
290290

291-
Async query data support enables an asynchronous query handling flow. With async query data support enabled, queries are handled over multiple requests (starting, checking its status, and fetching the results) instead of starting and resolving a query over a single request. This is useful for queries that can potentially run for a long time and timeout.
291+
Async query data support enables an asynchronous query handling flow. Queries are handled over multiple requests (starting, checking its status, and fetching the results) instead of starting and resolving a query over a single request. This is useful for queries that can potentially run for a long time and timeout.
292292

293-
To enable async query data support, you need to set feature toggle `athenaAsyncQueryDataSupport` to `true`. See [Configure feature toggles](https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#feature_toggles) for details.
293+
Async query data support is enabled by default in all Athena datasources.
294294

295295
### Async Query Caching
296296

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "grafana-athena-datasource",
3-
"version": "2.13.6",
3+
"version": "2.14.0",
44
"description": "Use Amazon Athena with Grafana",
55
"scripts": {
66
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
@@ -23,7 +23,7 @@
2323
"author": "Grafana Labs",
2424
"license": "Apache-2.0",
2525
"dependencies": {
26-
"@grafana/async-query-data": "0.1.11",
26+
"@grafana/async-query-data": "0.2.0",
2727
"@grafana/experimental": "1.7.0"
2828
},
2929
"devDependencies": {

src/ConfigEditor.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React, { FormEvent, useCallback, useEffect, useState } from 'react';
2-
import { DataSourcePluginOptionsEditorProps, DataSourceSettings, SelectableValue } from '@grafana/data';
2+
import { DataSourcePluginOptionsEditorProps, DataSourceSettings, GrafanaTheme2, SelectableValue } from '@grafana/data';
33
import { AthenaDataSourceOptions, AthenaDataSourceSecureJsonData, AthenaDataSourceSettings, defaultKey } from './types';
44
import { config, getBackendSrv } from '@grafana/runtime';
55
import { AwsAuthType, ConfigSelect, ConnectionConfig, Divider, InlineInput } from '@grafana/aws-sdk';
66
import { selectors } from 'tests/selectors';
77
import { ConfigSection } from '@grafana/experimental';
8-
import { Field, Input } from '@grafana/ui';
8+
import { Field, Input, useStyles2 } from '@grafana/ui';
9+
import { css } from '@emotion/css';
910

1011
type Props = DataSourcePluginOptionsEditorProps<AthenaDataSourceOptions, AthenaDataSourceSecureJsonData>;
1112

@@ -17,7 +18,8 @@ export function ConfigEditor(props: Props) {
1718
const [saved, setSaved] = useState(!!props.options.jsonData.defaultRegion);
1819
const [externalId, setExternalId] = useState('');
1920
const newFormStylingEnabled = config.featureToggles.awsDatasourcesNewFormStyling;
20-
21+
const styles = useStyles2(getStyles);
22+
2123
const saveOptions = async () => {
2224
if (saved) {
2325
return;
@@ -99,7 +101,7 @@ export function ConfigEditor(props: Props) {
99101
};
100102

101103
return (
102-
<div className="width-30">
104+
<div className={styles.formStyles}>
103105
<ConnectionConfig
104106
{...props}
105107
onOptionsChange={onOptionsChange}
@@ -223,3 +225,9 @@ export function ConfigEditor(props: Props) {
223225
</div>
224226
);
225227
}
228+
229+
const getStyles = (theme: GrafanaTheme2) => ({
230+
formStyles: css({
231+
maxWidth: theme.spacing(50),
232+
}),
233+
});

src/QueryEditor.test.tsx

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { fireEvent, render, screen } from '@testing-library/react';
1+
import { render, screen } from '@testing-library/react';
22
import { QueryEditor } from 'QueryEditor';
33
import React from 'react';
44
import { mockDatasource, mockQuery } from './__mocks__/datasource';
55
import * as experimental from '@grafana/experimental';
6-
import * as runtime from '@grafana/runtime';
7-
import { config } from '@grafana/runtime';
86

97
const ds = mockDatasource;
108
const q = { ...mockQuery, rawSQL: '' };
@@ -28,14 +26,6 @@ const props = {
2826
onChange: jest.fn(),
2927
onRunQuery: jest.fn(),
3028
};
31-
jest.mock('@grafana/runtime', () => ({
32-
...jest.requireActual<typeof runtime>('@grafana/runtime'),
33-
config: {
34-
featureToggles: {
35-
athenaAsyncQueryDataSupport: true,
36-
},
37-
},
38-
}));
3929

4030
beforeEach(() => {
4131
ds.getResource = jest.fn().mockResolvedValue([]);
@@ -48,28 +38,9 @@ describe('Query Editor', () => {
4838
const runButton = screen.getByRole('button', { name: 'Run query' });
4939
expect(runButton).toBeDisabled();
5040
});
51-
it('should show cancel button if athenaAsyncQueryDataSupport feature is enabled', () => {
41+
it('should show cancel button', () => {
5242
render(<QueryEditor {...props} />);
5343
const cancelButton = screen.getByRole('button', { name: 'Stop query' });
5444
expect(cancelButton).toBeInTheDocument();
5545
});
56-
it('should not show cancel button if athenaAsyncQueryDataSupport feature is disabled', () => {
57-
config.featureToggles.athenaAsyncQueryDataSupport = false;
58-
render(<QueryEditor {...props} />);
59-
const cancelButton = screen.queryByRole('button', { name: 'Stop query' });
60-
expect(cancelButton).not.toBeInTheDocument();
61-
});
62-
it('should re-enable Run query button if there is a change to the query', async () => {
63-
render(<QueryEditor {...props} query={{ ...props.query, rawSQL: 'initial query' }} />);
64-
const runButton = screen.getByRole('button', { name: 'Run query' });
65-
expect(runButton).toBeDisabled();
66-
67-
const input = screen.getByTestId('codeEditor');
68-
expect(input).toBeDefined();
69-
70-
fireEvent.change(input, { target: { value: 'test query' } });
71-
72-
expect(props.onChange).toHaveBeenCalledWith({ ...props.query, rawSQL: 'test query' });
73-
expect(runButton).not.toBeDisabled();
74-
});
7546
});

src/QueryEditor.tsx

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,22 @@
1-
import React, { useCallback, useEffect, useState } from 'react';
2-
import { config } from '@grafana/runtime';
1+
import React from 'react';
32
import { QueryEditorProps } from '@grafana/data';
43
import { AthenaDataSourceOptions, AthenaQuery } from './types';
54
import { DataSource } from './datasource';
65
import { QueryEditorForm } from './QueryEditorForm';
76
import { QueryEditorHeader } from '@grafana/aws-sdk';
87

98
export function QueryEditor(props: QueryEditorProps<DataSource, AthenaQuery, AthenaDataSourceOptions>) {
10-
const [dataIsStale, setDataIsStale] = useState(false);
11-
const { onChange } = props;
12-
13-
useEffect(() => {
14-
setDataIsStale(false);
15-
}, [props.data]);
16-
17-
const onChangeInternal = useCallback(
18-
(query: AthenaQuery) => {
19-
setDataIsStale(true);
20-
onChange(query);
21-
},
22-
[onChange]
23-
);
24-
259
return (
2610
<>
2711
{props?.app !== 'explore' && (
2812
<QueryEditorHeader<DataSource, AthenaQuery, AthenaDataSourceOptions>
2913
{...props}
30-
enableRunButton={dataIsStale && !!props.query.rawSQL}
31-
showAsyncQueryButtons={config.featureToggles.athenaAsyncQueryDataSupport}
32-
cancel={config.featureToggles.athenaAsyncQueryDataSupport ? props.datasource.cancel : undefined}
14+
enableRunButton={!!props.query.rawSQL}
15+
showAsyncQueryButtons
16+
cancel={props.datasource.cancel}
3317
/>
3418
)}
35-
<QueryEditorForm {...props} onChange={onChangeInternal} />
19+
<QueryEditorForm {...props} />
3620
</>
3721
);
3822
}

src/QueryEditorForm.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jest.mock('@grafana/runtime', () => ({
2929
...jest.requireActual<typeof runtime>('@grafana/runtime'),
3030
config: {
3131
featureToggles: {
32-
athenaAsyncQueryDataSupport: true,
3332
awsDatasourcesNewFormStyling: false,
3433
},
3534
},

src/datasource.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { DataQueryRequest, DataSourceInstanceSettings, dateTime } from '@grafana/data';
22
import * as runtime from '@grafana/runtime';
3+
import { DatasourceWithAsyncBackend } from '@grafana/async-query-data';
34
import { AthenaDataSourceOptions, AthenaQuery, FormatOptions } from 'types';
45
import { of } from 'rxjs';
56

@@ -189,10 +190,11 @@ describe('AthenaDatasource', () => {
189190
expect(queries[0].connectionArgs.region).toEqual('replaced');
190191
});
191192
});
193+
192194
it('should not run query if query is empty', async () => {
193195
const mockedSuperQuery = jest
194-
.spyOn(runtime.DataSourceWithBackend.prototype, 'query')
195-
.mockImplementation((request: DataQueryRequest<AthenaQuery>) => of());
196+
.spyOn(DatasourceWithAsyncBackend.prototype, 'query')
197+
.mockImplementation(() => of({ data: [] }));
196198

197199
const request = { ...queryRequest, targets: [{ ...defaultQuery, rawSQL: '' }] };
198200
ctx.ds.query(request);

src/datasource.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DataQueryRequest, DataQueryResponse, DataSourceInstanceSettings, ScopedVars } from '@grafana/data';
2-
import { config, getTemplateSrv, TemplateSrv } from '@grafana/runtime';
2+
import { getTemplateSrv, TemplateSrv } from '@grafana/runtime';
33
import { AthenaDataSourceOptions, AthenaQuery } from './types';
44
import { AthenaVariableSupport } from './variables';
55
import { filterSQLQuery, applySQLTemplateVariables } from '@grafana/aws-sdk';
@@ -19,7 +19,7 @@ export class DataSource extends DatasourceWithAsyncBackend<AthenaQuery, AthenaDa
1919
instanceSettings: DataSourceInstanceSettings<AthenaDataSourceOptions>,
2020
private readonly templateSrv: TemplateSrv = getTemplateSrv()
2121
) {
22-
super(instanceSettings, config.featureToggles.athenaAsyncQueryDataSupport);
22+
super(instanceSettings);
2323
this.defaultRegion = instanceSettings.jsonData.defaultRegion || '';
2424
this.defaultCatalog = instanceSettings.jsonData.catalog || '';
2525
this.defaultDatabase = instanceSettings.jsonData.database || '';

yarn.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,20 +1557,20 @@
15571557
dependencies:
15581558
tslib "^2.4.0"
15591559

1560-
"@grafana/[email protected]":
1561-
version "0.1.11"
1562-
resolved "https://registry.yarnpkg.com/@grafana/async-query-data/-/async-query-data-0.1.11.tgz#9964e3ffb25328151d00b67b25a04a5c5c133dd6"
1563-
integrity sha512-RW2sthimO+0xZl1K6dLWs9F4idvOQ+m/GRgnhuo7LWNYUYkrxlLsFZ6Yz9aRFq1Rkf5HsV0/ldFWlQNmxuL9tQ==
1564-
dependencies:
1565-
tslib "^2.4.1"
1566-
15671560
"@grafana/[email protected]":
15681561
version "0.1.4"
15691562
resolved "https://registry.yarnpkg.com/@grafana/async-query-data/-/async-query-data-0.1.4.tgz#ac24e32822a8032dd1ee10ce7dcb8c2e276c58b0"
15701563
integrity sha512-3d7fm2sf5x/+JKTt4T6MSS/veB2J/YGfQp5Ck0Tbqtc5YIoI0p1JY+vFWfCstEHyVd1H0Ep/q/VSxf4VAs9YKQ==
15711564
dependencies:
15721565
tslib "^2.4.1"
15731566

1567+
"@grafana/[email protected]":
1568+
version "0.2.0"
1569+
resolved "https://registry.yarnpkg.com/@grafana/async-query-data/-/async-query-data-0.2.0.tgz#2df8a69da527ce1993fc74a6bce452582fb76649"
1570+
integrity sha512-CduRkX8Bl8/+uiDTrKXjPN2h3kjVE67VgeZAZlVKcjCsxDlDpbVYXMVbfTJBGr4HqzDHg1Km6UkmeuOAt2bBww==
1571+
dependencies:
1572+
tslib "^2.4.1"
1573+
15741574
"@grafana/[email protected]":
15751575
version "0.3.1"
15761576
resolved "https://registry.yarnpkg.com/@grafana/aws-sdk/-/aws-sdk-0.3.1.tgz#0ada1b06c13882320ae2c07e7b2bbd703091da7c"

0 commit comments

Comments
 (0)