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

fixed create table async query bug #158

Merged
merged 7 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 : [],
paulstn marked this conversation as resolved.
Show resolved Hide resolved
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
Loading