Skip to content

Commit

Permalink
added changes for cancel query not being able to cancel, added back t…
Browse files Browse the repository at this point in the history
…icks (#256) (#258)

Signed-off-by: sumukhswamy <[email protected]>
Signed-off-by: Sumukh Swamy <[email protected]>
(cherry picked from commit 886af5f)

Co-authored-by: Sumukh Swamy <[email protected]>
  • Loading branch information
ps48 and sumukhswamy authored Feb 6, 2024
1 parent 82523af commit c1091c0
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 44 deletions.
2 changes: 1 addition & 1 deletion common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const TREE_ITEM_TABLE_NAME_DEFAULT_NAME = `table`;
export const TREE_ITEM_LOAD_MATERIALIZED_BADGE_NAME = `Load Materialized View`;
export const TREE_ITEM_BADGE_NAME = `badge`;
export const LOAD_OPENSEARCH_INDICES_QUERY = `SHOW tables LIKE '%';`;
export const SKIPPING_INDEX_QUERY = `CREATE SKIPPING INDEX ON datasource.database.table
export const SKIPPING_INDEX_QUERY = `CREATE SKIPPING INDEX ON \`datasource\`.\`database\`.\`table\`
(status VALUE_SET)
WITH (
auto_refresh = true,
Expand Down
17 changes: 12 additions & 5 deletions common/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface RefreshIntervalType {
refreshInterval: string;
}

export interface watermarkDelayType {
export interface WatermarkDelayType {
delayWindow: number;
delayInterval: string;
}
Expand All @@ -45,7 +45,7 @@ export interface GroupByTumbleType {
tumbleInterval: string;
}

export interface materializedViewQueryType {
export interface MaterializedViewQueryType {
columnsValues: MaterializedViewColumn[];
groupByTumbleValue: GroupByTumbleType;
}
Expand Down Expand Up @@ -75,18 +75,25 @@ export interface CreateAccelerationForm {
accelerationIndexType: AccelerationIndexType;
skippingIndexQueryData: SkippingIndexRowType[];
coveringIndexQueryData: string[];
materializedViewQueryData: materializedViewQueryType;
materializedViewQueryData: MaterializedViewQueryType;
accelerationIndexName: string;
primaryShardsCount: number;
replicaShardsCount: number;
refreshType: AccelerationRefreshType;
checkpointLocation: string | undefined;
watermarkDelay: watermarkDelayType;
watermarkDelay: WatermarkDelayType;
refreshIntervalOptions: RefreshIntervalType;
formErrors: FormErrorsType;
}

export type AsyncQueryLoadingStatus = 'SUCCESS' | 'FAILED' | 'RUNNING' | 'SCHEDULED' | 'CANCELLED';
export enum AsyncQueryLoadingStatus {
Success = 'success',
Failed = 'failed',
Running = 'running',
Scheduled = 'scheduled',
Cancelled = 'cancelled',
}

export type TreeItemType =
| 'covering_index'
| 'skipping_index'
Expand Down
14 changes: 7 additions & 7 deletions public/components/Main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class Main extends React.Component<MainProps, MainState> {
isResultFullScreen: false,
selectedDatasource: [{ label: 'OpenSearch' }],
asyncLoading: false,
asyncLoadingStatus: 'SUCCESS',
asyncLoadingStatus: AsyncQueryLoadingStatus.Success,
asyncQueryError: '',
asyncJobId: '',
refreshTree: false,
Expand Down Expand Up @@ -424,7 +424,7 @@ export class Main extends React.Component<MainProps, MainState> {
queryResultsTEXT: [],
searchQuery: '',
asyncLoading: false,
asyncLoadingStatus: 'SUCCESS',
asyncLoadingStatus: AsyncQueryLoadingStatus.Success,
isCallOutVisible: false,
},
() => console.log('Successfully updated the states')
Expand Down Expand Up @@ -497,7 +497,7 @@ export class Main extends React.Component<MainProps, MainState> {
selectedTabName: MESSAGE_TAB_LABEL,
itemIdToExpandedRowMap: {},
asyncLoading: true,
asyncLoadingStatus: 'SCHEDULED',
asyncLoadingStatus: AsyncQueryLoadingStatus.Scheduled,
asyncJobId: queryId,
isCallOutVisible: false,
});
Expand Down Expand Up @@ -533,8 +533,8 @@ export class Main extends React.Component<MainProps, MainState> {
const result: ResponseDetail<string> = this.processQueryResponse(
response as IHttpResponse<ResponseData>
);
const status = result.data.status;
if (_.isEqual(status, 'SUCCESS')) {
const status = result.data.status.toLowerCase();
if (_.isEqual(status, 'success')) {
const resultTable: Array<ResponseDetail<QueryResult>> = getQueryResultsForTable(
[result],
false
Expand All @@ -555,7 +555,7 @@ export class Main extends React.Component<MainProps, MainState> {
asyncLoadingStatus: status,
isCallOutVisible: !(result.data.schema.length > 0),
});
} else if (_.isEqual(status, 'FAILED') || _.isEqual(status, 'CANCELLED')) {
} else if (_.isEqual(status, 'failed') || _.isEqual(status, 'cancelled')) {
this.setState({
asyncLoading: false,
asyncLoadingStatus: status,
Expand Down Expand Up @@ -792,7 +792,7 @@ export class Main extends React.Component<MainProps, MainState> {
selectedTabName: MESSAGE_TAB_LABEL,
itemIdToExpandedRowMap: {},
asyncLoading: false,
asyncLoadingStatus: 'SUCCESS',
asyncLoadingStatus: AsyncQueryLoadingStatus.Success,
isCallOutVisible: false,
});
};
Expand Down
10 changes: 6 additions & 4 deletions public/components/QueryResults/QueryResults.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import '@testing-library/jest-dom/extend-expect';
import { configure, fireEvent, render } from '@testing-library/react';
import { AsyncQueryLoadingStatus } from "../../../common/types/index";

import 'mutationobserver-shim';
import React from 'react';
import 'regenerator-runtime';
Expand Down Expand Up @@ -53,7 +55,7 @@ function renderSQLQueryResults(
getText={getText}
isResultFullScreen={false}
setIsResultFullScreen={setIsResultFullScreen}
asyncLoadingStatus="SUCCESS"
asyncLoadingStatus={AsyncQueryLoadingStatus.Success}
asyncQueryError=""
selectedDatasource={[{ label: 'OpenSearch' }]}
cancelAsyncQuery={() => {}}
Expand Down Expand Up @@ -215,7 +217,7 @@ function renderPPLQueryResults(
getText={getText}
isResultFullScreen={false}
setIsResultFullScreen={setIsResultFullScreen}
asyncLoadingStatus="SUCCESS"
asyncLoadingStatus={AsyncQueryLoadingStatus.Success}
asyncQueryError=""
selectedDatasource={[{ label: 'OpenSearch' }]}
cancelAsyncQuery={() => {}}
Expand Down Expand Up @@ -341,7 +343,7 @@ describe('<AsyncQueryResults /> spec', () => {
getText={() => {}}
isResultFullScreen={false}
setIsResultFullScreen={() => {}}
asyncLoadingStatus="RUNNING"
asyncLoadingStatus={AsyncQueryLoadingStatus.Running}
asyncQueryError=""
selectedDatasource={[{ label: 'mys3' }]}
cancelAsyncQuery={() => {}}
Expand Down Expand Up @@ -378,7 +380,7 @@ describe('<AsyncQueryResults /> spec', () => {
getText={() => {}}
isResultFullScreen={false}
setIsResultFullScreen={() => {}}
asyncLoadingStatus="FAILED"
asyncLoadingStatus={AsyncQueryLoadingStatus.Failed}
asyncQueryError="custom error"
selectedDatasource={[{ label: 'mys3' }]}
cancelAsyncQuery={() => {}}
Expand Down
4 changes: 2 additions & 2 deletions public/components/QueryResults/QueryResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ class QueryResults extends React.Component<QueryResultsProps, QueryResultsState>
</EuiFlexItem>
</EuiFlexGroup>
</div>
{this.props.asyncLoadingStatus === 'SUCCESS' ||
this.props.asyncLoadingStatus === 'CANCELLED' ? (
{this.props.asyncLoadingStatus === 'success' ||
this.props.asyncLoadingStatus === 'cancelled' ? (
<>
{this.props.queryResults.length === 0 ? (
// show no results message instead of the results table when there are no results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ exports[`<AsyncQueryResults /> spec renders async query loading component 1`] =
class="euiText euiText--medium"
>
Status:
RUNNING
running
</div>
<button
class="euiButton euiButton--primary"
Expand Down
10 changes: 5 additions & 5 deletions public/components/QueryResults/async_query_body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
*/

import {
EuiFlexGroup,
EuiText,
EuiLoadingSpinner,
EuiButton,
EuiFlexGroup,
EuiIcon,
EuiLoadingSpinner,
EuiModal,
EuiModalBody,
EuiModalFooter,
EuiModalHeader,
EuiModalHeaderTitle,
EuiText,
} from '@elastic/eui';
import { AsyncQueryLoadingStatus } from '../../../common/types';
import React, { useState } from 'react';
import { AsyncQueryLoadingStatus } from '../../../common/types';

interface AsyncQueryBodyProps {
asyncLoadingStatus: AsyncQueryLoadingStatus;
Expand Down Expand Up @@ -51,7 +51,7 @@ export function AsyncQueryBody(props: AsyncQueryBodyProps) {

return (
<EuiFlexGroup direction="column" alignItems="center">
{asyncLoadingStatus == 'FAILED' ? (
{asyncLoadingStatus == AsyncQueryLoadingStatus.Failed ? (
<>
<EuiIcon size="l" type="alert" color="danger" />
<EuiText>
Expand Down
12 changes: 6 additions & 6 deletions public/components/SQLPage/table_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const TableView = ({ http, selectedItems, updateSQLQueries, refreshTree }
setTableNames([]);
const query = {
lang: 'sql',
query: `SHOW SCHEMAS IN ${selectedItems[0].label}`,
query: `SHOW SCHEMAS IN \`${selectedItems[0]['label']}\``,
datasource: selectedItems[0].label,
};
getJobId(selectedItems[0].label, query, http, (id) => {
Expand Down Expand Up @@ -202,7 +202,7 @@ export const TableView = ({ http, selectedItems, updateSQLQueries, refreshTree }
setSelectedDatabase(databaseName);
const query = {
lang: 'sql',
query: `SHOW TABLES IN ${selectedItems[0].label}.${databaseName}`,
query: `SHOW TABLES IN \`${selectedItems[0]['label']}\`.\`${databaseName}\``,
datasource: selectedItems[0].label,
};
getJobId(selectedItems[0].label, query, http, (id) => {
Expand Down Expand Up @@ -270,7 +270,7 @@ export const TableView = ({ http, selectedItems, updateSQLQueries, refreshTree }
const loadCoveringIndex = (tableName: string, databaseName: string) => {
const coverQuery = {
lang: 'sql',
query: `SHOW INDEX ON ${selectedItems[0].label}.${databaseName}.${tableName}`,
query: `SHOW INDEX ON \`${selectedItems[0]['label']}\`.\`${databaseName}\`.\`${tableName}\``,
datasource: selectedItems[0].label,
};
getJobId(selectedItems[0].label, coverQuery, http, (id) => {
Expand Down Expand Up @@ -354,7 +354,7 @@ export const TableView = ({ http, selectedItems, updateSQLQueries, refreshTree }
setLoadingForTableElements(databaseName, tableName);
const materializedViewQuery = {
lang: 'sql',
query: `SHOW MATERIALIZED VIEW IN ${selectedItems[0].label}.${databaseName}`,
query: `SHOW MATERIALIZED VIEW IN \`${selectedItems[0]['label']}\`.\`${databaseName}\``,
datasource: selectedItems[0].label,
};
getJobId(selectedItems[0].label, materializedViewQuery, http, (id) => {
Expand Down Expand Up @@ -418,7 +418,7 @@ export const TableView = ({ http, selectedItems, updateSQLQueries, refreshTree }
setLoadingForTableElements(databaseName, tableName);
const skipQuery = {
lang: 'sql',
query: `DESC SKIPPING INDEX ON ${selectedItems[0].label}.${databaseName}.${tableName}`,
query: `DESC SKIPPING INDEX ON \`${selectedItems[0]['label']}\`.\`${databaseName}\`.\`${tableName}\``,
datasource: selectedItems[0].label,
};
getJobId(selectedItems[0].label, skipQuery, http, (id) => {
Expand Down Expand Up @@ -472,7 +472,7 @@ export const TableView = ({ http, selectedItems, updateSQLQueries, refreshTree }
};
const handleQuery = (e: MouseEvent, parentName: string, tableName: string) => {
e.stopPropagation();
updateSQLQueries(`select * from ${selectedItems[0].label}.${parentName}.${tableName} limit 10`);
updateSQLQueries(`select * from \`${selectedItems[0].label}\`.\`${parentName}\`.\`${tableName}\` limit 10`);
};

const iconCreation = (node: TreeItem) => {
Expand Down
4 changes: 2 additions & 2 deletions public/components/acceleration/create/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
AccelerationRefreshType,
CreateAccelerationForm,
FormErrorsType,
MaterializedViewQueryType,
SkippingIndexRowType,
materializedViewQueryType,
} from '../../../../common/types';

export const pluralizeTime = (timeWindow: number) => {
Expand Down Expand Up @@ -103,7 +103,7 @@ export const validateCoveringIndexData = (

export const validateMaterializedViewData = (
accelerationIndexType: AccelerationIndexType,
materializedViewQueryData: materializedViewQueryType
materializedViewQueryData: MaterializedViewQueryType
) => {
if (accelerationIndexType !== 'materialized') return [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const IndexTypeSelector = ({
const idPrefix = htmlIdGenerator()();
const query = {
lang: 'sql',
query: `DESC ${accelerationFormData.dataSource}.${accelerationFormData.database}.${accelerationFormData.dataTable}`,
query: `DESC \`${accelerationFormData.dataSource}\`.\`${accelerationFormData.database}\`.\`${accelerationFormData.dataTable}\``,
datasource: accelerationFormData.dataSource,
};
const errorMessage = 'ERROR: failed to load table columns';
Expand Down
4 changes: 2 additions & 2 deletions public/components/acceleration/selectors/source_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const AccelerationDataSourceSelector = ({
setLoadingComboBoxes({ ...loadingComboBoxes, database: true });
const query = {
lang: 'sql',
query: `SHOW SCHEMAS IN ${accelerationFormData.dataSource}`,
query: `SHOW SCHEMAS IN \`${accelerationFormData.dataSource}\``,
datasource: accelerationFormData.dataSource,
};
const errorMessage = `ERROR: failed to load databases`;
Expand Down Expand Up @@ -96,7 +96,7 @@ export const AccelerationDataSourceSelector = ({
setLoadingComboBoxes({ ...loadingComboBoxes, dataTable: true });
const query = {
lang: 'sql',
query: `SHOW TABLES IN ${accelerationFormData.dataSource}.${accelerationFormData.database}`,
query: `SHOW TABLES IN \`${accelerationFormData.dataSource}.\`${accelerationFormData.database}\``,
datasource: accelerationFormData.dataSource,
};
const errorMessage = `ERROR: failed to load tables`;
Expand Down
16 changes: 8 additions & 8 deletions test/mocks/accelerationMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
*/

import {
ACCELERATION_DEFUALT_SKIPPING_INDEX_NAME,
ACCELERATION_TIME_INTERVAL,
ACCELERATION_DEFUALT_SKIPPING_INDEX_NAME,
ACCELERATION_TIME_INTERVAL,
} from '../../common/constants';
import {
CreateAccelerationForm,
SkippingIndexRowType,
materializedViewQueryType,
CreateAccelerationForm,
MaterializedViewQueryType,
SkippingIndexRowType,
} from '../../common/types';

export const skippingIndexDataMock: SkippingIndexRowType[] = [
Expand Down Expand Up @@ -39,7 +39,7 @@ export const materializedViewEmptyDataMock = {
},
};

export const materializedViewEmptyTumbleDataMock: materializedViewQueryType = {
export const materializedViewEmptyTumbleDataMock: MaterializedViewQueryType = {
columnsValues: [
{
id: '1',
Expand All @@ -54,7 +54,7 @@ export const materializedViewEmptyTumbleDataMock: materializedViewQueryType = {
},
};

export const materializedViewStaleDataMock: materializedViewQueryType = {
export const materializedViewStaleDataMock: MaterializedViewQueryType = {
columnsValues: [],
groupByTumbleValue: {
timeField: 'timestamp',
Expand All @@ -63,7 +63,7 @@ export const materializedViewStaleDataMock: materializedViewQueryType = {
},
};

export const materializedViewValidDataMock: materializedViewQueryType = {
export const materializedViewValidDataMock: MaterializedViewQueryType = {
columnsValues: [
{
id: '1',
Expand Down

0 comments on commit c1091c0

Please sign in to comment.