From de736f165076bb7ac63374449f569223f0cf30e5 Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Thu, 31 Oct 2024 17:02:15 -0700 Subject: [PATCH 1/3] update async search reponse type Signed-off-by: Shenoy Pratik --- .../server/search/ppl_async_search_strategy.ts | 6 +++++- .../server/search/sql_async_search_strategy.ts | 14 +++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/plugins/query_enhancements/server/search/ppl_async_search_strategy.ts b/src/plugins/query_enhancements/server/search/ppl_async_search_strategy.ts index ede0d51b62c7..de30123f3aec 100644 --- a/src/plugins/query_enhancements/server/search/ppl_async_search_strategy.ts +++ b/src/plugins/query_enhancements/server/search/ppl_async_search_strategy.ts @@ -14,6 +14,7 @@ import { } from '../../../data/common'; import { ISearchStrategy, SearchUsage } from '../../../data/server'; import { buildQueryStatusConfig, getFields, handleFacetError, SEARCH_STRATEGY } from '../../common'; +import { FacetResponse } from '../types'; import { Facet } from '../utils'; export const pplAsyncSearchStrategyProvider = ( @@ -58,7 +59,10 @@ export const pplAsyncSearchStrategyProvider = ( } as IDataFrameResponse; } else { request.params = { queryId: inProgressQueryId }; - const queryStatusResponse: any = await pplAsyncJobsFacet.describeQuery(context, request); + const queryStatusResponse: FacetResponse = await pplAsyncJobsFacet.describeQuery( + context, + request + ); if (!queryStatusResponse.success) handleFacetError(queryStatusResponse); diff --git a/src/plugins/query_enhancements/server/search/sql_async_search_strategy.ts b/src/plugins/query_enhancements/server/search/sql_async_search_strategy.ts index eda7997c1b63..159237f9c13b 100644 --- a/src/plugins/query_enhancements/server/search/sql_async_search_strategy.ts +++ b/src/plugins/query_enhancements/server/search/sql_async_search_strategy.ts @@ -3,18 +3,19 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { SharedGlobalConfig, Logger, ILegacyClusterClient } from 'opensearch-dashboards/server'; +import { ILegacyClusterClient, Logger, SharedGlobalConfig } from 'opensearch-dashboards/server'; import { Observable } from 'rxjs'; -import { ISearchStrategy, SearchUsage } from '../../../data/server'; import { + createDataFrame, DATA_FRAME_TYPES, IDataFrameResponse, IOpenSearchDashboardsSearchRequest, Query, - createDataFrame, } from '../../../data/common'; -import { Facet } from '../utils'; +import { ISearchStrategy, SearchUsage } from '../../../data/server'; import { buildQueryStatusConfig, getFields, handleFacetError, SEARCH_STRATEGY } from '../../common'; +import { FacetResponse } from '../types'; +import { Facet } from '../utils'; export const sqlAsyncSearchStrategyProvider = ( config$: Observable, @@ -58,7 +59,10 @@ export const sqlAsyncSearchStrategyProvider = ( } as IDataFrameResponse; } else { request.params = { queryId: inProgressQueryId }; - const queryStatusResponse: any = await sqlAsyncJobsFacet.describeQuery(context, request); + const queryStatusResponse: FacetResponse = await sqlAsyncJobsFacet.describeQuery( + context, + request + ); if (!queryStatusResponse.success) handleFacetError(queryStatusResponse); From 57d96f328cf9619383db298ca4b6abf4dadb7275 Mon Sep 17 00:00:00 2001 From: "opensearch-changeset-bot[bot]" <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 00:05:37 +0000 Subject: [PATCH 2/3] Changeset file for PR #8781 created/updated --- changelogs/fragments/8781.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/8781.yml diff --git a/changelogs/fragments/8781.yml b/changelogs/fragments/8781.yml new file mode 100644 index 000000000000..cee2381aadf5 --- /dev/null +++ b/changelogs/fragments/8781.yml @@ -0,0 +1,2 @@ +fix: +- Update async search response type ([#8781](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8781)) \ No newline at end of file From 306cd4f42a1d5db19eed7f2860890c57f34de49a Mon Sep 17 00:00:00 2001 From: Shenoy Pratik Date: Thu, 31 Oct 2024 17:31:05 -0700 Subject: [PATCH 3/3] remove explicit type declaration Signed-off-by: Shenoy Pratik --- .../server/search/ppl_async_search_strategy.ts | 14 +++++--------- .../server/search/sql_async_search_strategy.ts | 14 +++++--------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/plugins/query_enhancements/server/search/ppl_async_search_strategy.ts b/src/plugins/query_enhancements/server/search/ppl_async_search_strategy.ts index de30123f3aec..309c5fd522b6 100644 --- a/src/plugins/query_enhancements/server/search/ppl_async_search_strategy.ts +++ b/src/plugins/query_enhancements/server/search/ppl_async_search_strategy.ts @@ -14,7 +14,6 @@ import { } from '../../../data/common'; import { ISearchStrategy, SearchUsage } from '../../../data/server'; import { buildQueryStatusConfig, getFields, handleFacetError, SEARCH_STRATEGY } from '../../common'; -import { FacetResponse } from '../types'; import { Facet } from '../utils'; export const pplAsyncSearchStrategyProvider = ( @@ -59,25 +58,22 @@ export const pplAsyncSearchStrategyProvider = ( } as IDataFrameResponse; } else { request.params = { queryId: inProgressQueryId }; - const queryStatusResponse: FacetResponse = await pplAsyncJobsFacet.describeQuery( - context, - request - ); + const queryStatusResponse = await pplAsyncJobsFacet.describeQuery(context, request); if (!queryStatusResponse.success) handleFacetError(queryStatusResponse); - const queryStatus = queryStatusResponse?.data?.status; + const queryStatus = queryStatusResponse.data?.status; logger.info(`pplAsyncSearchStrategy: JOB: ${inProgressQueryId} - STATUS: ${queryStatus}`); if (queryStatus?.toUpperCase() === 'SUCCESS') { const dataFrame = createDataFrame({ name: query.dataset?.id, - schema: queryStatusResponse.data.schema, + schema: queryStatusResponse.data?.schema, meta: { ...pollQueryResultsParams }, fields: getFields(queryStatusResponse), }); - dataFrame.size = queryStatusResponse.data.datarows.length; + dataFrame.size = queryStatusResponse.data?.datarows.length; return { type: DATA_FRAME_TYPES.POLLING, @@ -89,7 +85,7 @@ export const pplAsyncSearchStrategyProvider = ( type: DATA_FRAME_TYPES.POLLING, status: 'failed', body: { - error: `JOB: ${inProgressQueryId} failed: ${queryStatusResponse.data.error}`, + error: `JOB: ${inProgressQueryId} failed: ${queryStatusResponse.data?.error}`, }, } as IDataFrameResponse; } diff --git a/src/plugins/query_enhancements/server/search/sql_async_search_strategy.ts b/src/plugins/query_enhancements/server/search/sql_async_search_strategy.ts index 159237f9c13b..bc25f69a70f6 100644 --- a/src/plugins/query_enhancements/server/search/sql_async_search_strategy.ts +++ b/src/plugins/query_enhancements/server/search/sql_async_search_strategy.ts @@ -14,7 +14,6 @@ import { } from '../../../data/common'; import { ISearchStrategy, SearchUsage } from '../../../data/server'; import { buildQueryStatusConfig, getFields, handleFacetError, SEARCH_STRATEGY } from '../../common'; -import { FacetResponse } from '../types'; import { Facet } from '../utils'; export const sqlAsyncSearchStrategyProvider = ( @@ -59,25 +58,22 @@ export const sqlAsyncSearchStrategyProvider = ( } as IDataFrameResponse; } else { request.params = { queryId: inProgressQueryId }; - const queryStatusResponse: FacetResponse = await sqlAsyncJobsFacet.describeQuery( - context, - request - ); + const queryStatusResponse = await sqlAsyncJobsFacet.describeQuery(context, request); if (!queryStatusResponse.success) handleFacetError(queryStatusResponse); - const queryStatus = queryStatusResponse?.data?.status; + const queryStatus = queryStatusResponse.data?.status; logger.info(`sqlAsyncSearchStrategy: JOB: ${inProgressQueryId} - STATUS: ${queryStatus}`); if (queryStatus?.toUpperCase() === 'SUCCESS') { const dataFrame = createDataFrame({ name: query.dataset?.id, - schema: queryStatusResponse.data.schema, + schema: queryStatusResponse.data?.schema, meta: { ...pollQueryResultsParams }, fields: getFields(queryStatusResponse), }); - dataFrame.size = queryStatusResponse.data.datarows.length; + dataFrame.size = queryStatusResponse.data?.datarows.length; return { type: DATA_FRAME_TYPES.POLLING, @@ -89,7 +85,7 @@ export const sqlAsyncSearchStrategyProvider = ( type: DATA_FRAME_TYPES.POLLING, status: 'failed', body: { - error: `JOB: ${inProgressQueryId} failed: ${queryStatusResponse.data.error}`, + error: `JOB: ${inProgressQueryId} failed: ${queryStatusResponse.data?.error}`, }, } as IDataFrameResponse; }