diff --git a/common/constants/index.ts b/common/constants/index.ts index 260eeade..4faaf334 100644 --- a/common/constants/index.ts +++ b/common/constants/index.ts @@ -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, diff --git a/common/types/index.ts b/common/types/index.ts index ad06694d..520c80fc 100644 --- a/common/types/index.ts +++ b/common/types/index.ts @@ -32,7 +32,7 @@ export interface RefreshIntervalType { refreshInterval: string; } -export interface watermarkDelayType { +export interface WatermarkDelayType { delayWindow: number; delayInterval: string; } @@ -45,7 +45,7 @@ export interface GroupByTumbleType { tumbleInterval: string; } -export interface materializedViewQueryType { +export interface MaterializedViewQueryType { columnsValues: MaterializedViewColumn[]; groupByTumbleValue: GroupByTumbleType; } @@ -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' diff --git a/public/components/Main/main.tsx b/public/components/Main/main.tsx index b0d6d1f9..26fb0fa8 100644 --- a/public/components/Main/main.tsx +++ b/public/components/Main/main.tsx @@ -259,7 +259,7 @@ export class Main extends React.Component { isResultFullScreen: false, selectedDatasource: [{ label: 'OpenSearch' }], asyncLoading: false, - asyncLoadingStatus: 'SUCCESS', + asyncLoadingStatus: AsyncQueryLoadingStatus.Success, asyncQueryError: '', asyncJobId: '', refreshTree: false, @@ -424,7 +424,7 @@ export class Main extends React.Component { queryResultsTEXT: [], searchQuery: '', asyncLoading: false, - asyncLoadingStatus: 'SUCCESS', + asyncLoadingStatus: AsyncQueryLoadingStatus.Success, isCallOutVisible: false, }, () => console.log('Successfully updated the states') @@ -497,7 +497,7 @@ export class Main extends React.Component { selectedTabName: MESSAGE_TAB_LABEL, itemIdToExpandedRowMap: {}, asyncLoading: true, - asyncLoadingStatus: 'SCHEDULED', + asyncLoadingStatus: AsyncQueryLoadingStatus.Scheduled, asyncJobId: queryId, isCallOutVisible: false, }); @@ -533,8 +533,8 @@ export class Main extends React.Component { const result: ResponseDetail = this.processQueryResponse( response as IHttpResponse ); - const status = result.data.status; - if (_.isEqual(status, 'SUCCESS')) { + const status = result.data.status.toLowerCase(); + if (_.isEqual(status, 'success')) { const resultTable: Array> = getQueryResultsForTable( [result], false @@ -555,7 +555,7 @@ export class Main extends React.Component { 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, @@ -792,7 +792,7 @@ export class Main extends React.Component { selectedTabName: MESSAGE_TAB_LABEL, itemIdToExpandedRowMap: {}, asyncLoading: false, - asyncLoadingStatus: 'SUCCESS', + asyncLoadingStatus: AsyncQueryLoadingStatus.Success, isCallOutVisible: false, }); }; diff --git a/public/components/QueryResults/QueryResults.test.tsx b/public/components/QueryResults/QueryResults.test.tsx index 7be490ae..66842369 100644 --- a/public/components/QueryResults/QueryResults.test.tsx +++ b/public/components/QueryResults/QueryResults.test.tsx @@ -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'; @@ -53,7 +55,7 @@ function renderSQLQueryResults( getText={getText} isResultFullScreen={false} setIsResultFullScreen={setIsResultFullScreen} - asyncLoadingStatus="SUCCESS" + asyncLoadingStatus={AsyncQueryLoadingStatus.Success} asyncQueryError="" selectedDatasource={[{ label: 'OpenSearch' }]} cancelAsyncQuery={() => {}} @@ -215,7 +217,7 @@ function renderPPLQueryResults( getText={getText} isResultFullScreen={false} setIsResultFullScreen={setIsResultFullScreen} - asyncLoadingStatus="SUCCESS" + asyncLoadingStatus={AsyncQueryLoadingStatus.Success} asyncQueryError="" selectedDatasource={[{ label: 'OpenSearch' }]} cancelAsyncQuery={() => {}} @@ -341,7 +343,7 @@ describe(' spec', () => { getText={() => {}} isResultFullScreen={false} setIsResultFullScreen={() => {}} - asyncLoadingStatus="RUNNING" + asyncLoadingStatus={AsyncQueryLoadingStatus.Running} asyncQueryError="" selectedDatasource={[{ label: 'mys3' }]} cancelAsyncQuery={() => {}} @@ -378,7 +380,7 @@ describe(' spec', () => { getText={() => {}} isResultFullScreen={false} setIsResultFullScreen={() => {}} - asyncLoadingStatus="FAILED" + asyncLoadingStatus={AsyncQueryLoadingStatus.Failed} asyncQueryError="custom error" selectedDatasource={[{ label: 'mys3' }]} cancelAsyncQuery={() => {}} diff --git a/public/components/QueryResults/QueryResults.tsx b/public/components/QueryResults/QueryResults.tsx index d4d46772..e55c89c9 100644 --- a/public/components/QueryResults/QueryResults.tsx +++ b/public/components/QueryResults/QueryResults.tsx @@ -336,8 +336,8 @@ class QueryResults extends React.Component - {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 diff --git a/public/components/QueryResults/__snapshots__/QueryResults.test.tsx.snap b/public/components/QueryResults/__snapshots__/QueryResults.test.tsx.snap index 50b235dc..e7b836c3 100644 --- a/public/components/QueryResults/__snapshots__/QueryResults.test.tsx.snap +++ b/public/components/QueryResults/__snapshots__/QueryResults.test.tsx.snap @@ -206,7 +206,7 @@ exports[` spec renders async query loading component 1`] = class="euiText euiText--medium" > Status: - RUNNING + running