Skip to content

Commit 1419447

Browse files
committed
fix: better error handling
1 parent 13a7375 commit 1419447

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/containers/Tenant/Query/QueryResult/QueryResultViewer.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {Ast} from './components/Ast/Ast';
2828
import {Graph} from './components/Graph/Graph';
2929
import {QueryInfoDropdown} from './components/QueryInfoDropdown/QueryInfoDropdown';
3030
import {QueryJSONViewer} from './components/QueryJSONViewer/QueryJSONViewer';
31+
import {QueryResultError} from './components/QueryResultError/QueryResultError';
3132
import {ResultSetsViewer} from './components/ResultSetsViewer/ResultSetsViewer';
3233
import {SimplifiedPlan} from './components/SimplifiedPlan/SimplifiedPlan';
3334
import {StubMessage} from './components/Stub/Stub';
@@ -254,7 +255,11 @@ export function QueryResultViewer({
254255
}
255256

256257
if (error) {
257-
return renderCommonErrorView(isStopped);
258+
return isExecute || isStopped ? (
259+
renderCommonErrorView(isStopped)
260+
) : (
261+
<QueryResultError error={error} />
262+
);
258263
}
259264

260265
if (activeSection === RESULT_OPTIONS_IDS.schema) {

tests/suites/tenant/queryEditor/queryEditor.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ test.describe('Test Query Editor', async () => {
7474
await expect(explainAST).toBeVisible({timeout: VISIBILITY_TIMEOUT});
7575
});
7676

77-
test('Error is displayed for invalid query', async ({page}) => {
77+
test('Error is displayed for invalid query for run', async ({page}) => {
7878
const queryEditor = new QueryEditor(page);
7979

8080
const invalidQuery = 'Select d';
@@ -86,6 +86,18 @@ test.describe('Test Query Editor', async () => {
8686
await expect(errorMessage).toContain('Column references are not allowed without FROM');
8787
});
8888

89+
test('Error is displayed for invalid query for explain', async ({page}) => {
90+
const queryEditor = new QueryEditor(page);
91+
92+
const invalidQuery = 'Select d';
93+
await queryEditor.setQuery(invalidQuery);
94+
await queryEditor.clickExplainButton();
95+
96+
await expect(queryEditor.waitForStatus('Failed')).resolves.toBe(true);
97+
const errorMessage = await queryEditor.getErrorMessage();
98+
await expect(errorMessage).toContain('Column references are not allowed without FROM');
99+
});
100+
89101
test('Run and Explain buttons are disabled when query is empty', async ({page}) => {
90102
const queryEditor = new QueryEditor(page);
91103

0 commit comments

Comments
 (0)