Skip to content

Commit

Permalink
fixed create table async query bug (#158)
Browse files Browse the repository at this point in the history
* avoid displaying results if no scheme is returned on success for async query

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* if there is no schema, will handle case by displaying success/failure regardless

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* success callout when no schema returned

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* added failure page to async

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* fixed some test errors and added snapshots

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* update to failure portion

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

* included tests of loading and failure states

Signed-off-by: Paul Sebastian <paulstn@amazon.com>

---------

Signed-off-by: Paul Sebastian <paulstn@amazon.com>
(cherry picked from commit 55d6352)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Oct 18, 2023
1 parent cf4a4d6 commit 3703628
Show file tree
Hide file tree
Showing 7 changed files with 621 additions and 94 deletions.
2 changes: 1 addition & 1 deletion common/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ export interface CreateAccelerationForm {
formErrors: FormErrorsType;
}

export type AsyncQueryLoadingStatus = 'SUCCESS' | 'FAILED' | 'RUNNING' | 'SCHEDULED' | 'CANCELED';
export type AsyncQueryLoadingStatus = 'SUCCESS' | 'FAILED' | 'RUNNING' | 'SCHEDULED' | 'CANCELLED';
37 changes: 34 additions & 3 deletions public/components/Main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
EuiPanel,
EuiSpacer,
EuiText,
EuiCallOut,
} from '@elastic/eui';
import { IHttpResponse } from 'angular';
import _ from 'lodash';
Expand Down Expand Up @@ -108,8 +109,10 @@ interface MainState {
selectedDatasource: EuiComboBoxOptionOption[];
asyncLoading: boolean;
asyncLoadingStatus: AsyncQueryLoadingStatus;
asyncQueryError: string;
asyncJobId: string;
isAccelerationFlyoutOpened: boolean;
isCallOutVisible: boolean;
}

const SUCCESS_MESSAGE = 'Success';
Expand Down Expand Up @@ -246,8 +249,10 @@ export class Main extends React.Component<MainProps, MainState> {
selectedDatasource: [{ label: 'OpenSearch' }],
asyncLoading: false,
asyncLoadingStatus: 'SUCCESS',
asyncQueryError: '',
asyncJobId: '',
isAccelerationFlyoutOpened: false,
isCallOutVisible: false,
};
this.httpClient = this.props.httpClient;
this.updateSQLQueries = _.debounce(this.updateSQLQueries, 250).bind(this);
Expand Down Expand Up @@ -403,6 +408,9 @@ export class Main extends React.Component<MainProps, MainState> {
queryResultsCSV: [],
queryResultsTEXT: [],
searchQuery: '',
asyncLoading: false,
asyncLoadingStatus: 'SUCCESS',
isCallOutVisible: false,
},
() => console.log('Successfully updated the states')
); // added callback function to handle async issues
Expand Down Expand Up @@ -474,6 +482,7 @@ export class Main extends React.Component<MainProps, MainState> {
asyncLoading: true,
asyncLoadingStatus: 'SCHEDULED',
asyncJobId: queryId,
isCallOutVisible: false,
});
this.callGetStartPolling(queries);
const interval = setInterval(() => {
Expand Down Expand Up @@ -513,7 +522,7 @@ export class Main extends React.Component<MainProps, MainState> {
this.setState({
queries: queries,
queryResults: [result],
queryResultsTable: resultTable,
queryResultsTable: result.data['schema'].length > 0 ? resultTable : [],
selectedTabId: getDefaultTabId([result]),
selectedTabName: getDefaultTabLabel([result], queries[0]),
messages: this.getMessage(resultTable),
Expand All @@ -524,6 +533,7 @@ export class Main extends React.Component<MainProps, MainState> {
searchQuery: '',
asyncLoading: false,
asyncLoadingStatus: status,
isCallOutVisible: !(result.data['schema'].length > 0),
});
} else if (_.isEqual(status, 'FAILED') || _.isEqual(status, 'CANCELLED')) {
this.setState({
Expand All @@ -535,6 +545,7 @@ export class Main extends React.Component<MainProps, MainState> {
className: 'error-message',
},
],
asyncQueryError: result.data['error'],
});
} else {
this.setState({
Expand Down Expand Up @@ -760,6 +771,9 @@ export class Main extends React.Component<MainProps, MainState> {
selectedTabId: MESSAGE_TAB_LABEL,
selectedTabName: MESSAGE_TAB_LABEL,
itemIdToExpandedRowMap: {},
asyncLoading: false,
asyncLoadingStatus: 'SUCCESS',
isCallOutVisible: false,
});
};

Expand Down Expand Up @@ -890,8 +904,8 @@ export class Main extends React.Component<MainProps, MainState> {
getText={this.getText}
isResultFullScreen={this.state.isResultFullScreen}
setIsResultFullScreen={this.setIsResultFullScreen}
asyncLoading={this.state.asyncLoading}
asyncLoadingStatus={this.state.asyncLoadingStatus}
asyncQueryError={this.state.asyncQueryError}
cancelAsyncQuery={this.cancelAsyncQuery}
selectedDatasource={this.state.selectedDatasource}
/>
Expand Down Expand Up @@ -956,6 +970,23 @@ export class Main extends React.Component<MainProps, MainState> {
<EuiSpacer size="l" />
<div>{page}</div>
<EuiSpacer size="l" />
{this.state.isCallOutVisible && (
<>
<EuiCallOut
size="s"
title="Query Submitted Successfully"
color="success"
iconType="check"
dismissible
onDismiss={() =>
this.setState({
isCallOutVisible: false,
})
}
/>
<EuiSpacer size="l" />
</>
)}
<div className="sql-console-query-result">
<QueryResults
language={this.state.language}
Expand Down Expand Up @@ -992,8 +1023,8 @@ export class Main extends React.Component<MainProps, MainState> {
getText={this.getText}
isResultFullScreen={this.state.isResultFullScreen}
setIsResultFullScreen={this.setIsResultFullScreen}
asyncLoading={this.state.asyncLoading}
asyncLoadingStatus={this.state.asyncLoadingStatus}
asyncQueryError={this.state.asyncQueryError}
cancelAsyncQuery={this.cancelAsyncQuery}
selectedDatasource={this.state.selectedDatasource}
/>
Expand Down
32 changes: 0 additions & 32 deletions public/components/QueryResults/AsyncQueryBody.tsx

This file was deleted.

Loading

0 comments on commit 3703628

Please sign in to comment.