Skip to content

Commit fd071f1

Browse files
[chat] Fix ppl execution tool incorrect status (#11112)
* Fix ppl execution tool incorrect status Signed-off-by: Lin Wang <wonglam@amazon.com> * Changeset file for PR #11112 created/updated * Fix failed unit tests Signed-off-by: Lin Wang <wonglam@amazon.com> --------- Signed-off-by: Lin Wang <wonglam@amazon.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
1 parent 3af700d commit fd071f1

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

changelogs/fragments/11112.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fix:
2+
- [chat] Fix ppl execution tool incorrect status ([#11112](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/11112))

src/plugins/explore/public/components/query_panel/actions/ppl_execute_query_action.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import { QueryExecutionStatus } from '../../../application/utils/state_management/types';
1313
import { useOpenSearchDashboards } from '../../../../../opensearch_dashboards_react/public';
1414
import { loadQueryActionCreator } from '../../../application/utils/state_management/actions/query_editor/load_query';
15-
import { defaultPrepareQueryString } from '../../../application/utils/state_management/actions/query_actions';
15+
import { prepareQueryForLanguage } from '../../../application/utils/languages';
1616
import { useDispatch } from 'react-redux';
1717

1818
// Mock dependencies
@@ -26,8 +26,8 @@ jest.mock('../../../application/utils/state_management/actions/query_editor/load
2626
loadQueryActionCreator: jest.fn(),
2727
}));
2828

29-
jest.mock('../../../application/utils/state_management/actions/query_actions', () => ({
30-
defaultPrepareQueryString: jest.fn(),
29+
jest.mock('../../../application/utils/languages', () => ({
30+
prepareQueryForLanguage: jest.fn(),
3131
}));
3232

3333
jest.mock('react-redux', () => ({
@@ -59,14 +59,14 @@ describe('usePPLExecuteQueryAction', () => {
5959
let mockUseOpenSearchDashboards: jest.Mock;
6060
let mockLoadQueryActionCreator: jest.Mock;
6161
let mockUseDispatch: jest.Mock;
62-
let mockDefaultPrepareQueryString: jest.Mock;
62+
let mockPrepareQueryForLanguage: jest.Mock;
6363
let mockDispatch: jest.Mock;
6464

6565
beforeEach(() => {
6666
// Get the mocked functions
6767
mockUseOpenSearchDashboards = useOpenSearchDashboards as jest.Mock;
6868
mockLoadQueryActionCreator = loadQueryActionCreator as jest.Mock;
69-
mockDefaultPrepareQueryString = defaultPrepareQueryString as jest.Mock;
69+
mockPrepareQueryForLanguage = prepareQueryForLanguage as jest.Mock;
7070
mockUseDispatch = useDispatch as jest.Mock;
7171
mockDispatch = jest.fn();
7272

@@ -95,7 +95,7 @@ describe('usePPLExecuteQueryAction', () => {
9595
// Setup mocks
9696
mockUseOpenSearchDashboards.mockReturnValue({ services: mockServices });
9797
mockLoadQueryActionCreator.mockReturnValue({ type: 'LOAD_QUERY' });
98-
mockDefaultPrepareQueryString.mockReturnValue('test-cache-key');
98+
mockPrepareQueryForLanguage.mockReturnValue({ query: 'test-cache-key' });
9999
mockSetEditorTextWithQuery = jest.fn();
100100
mockUseDispatch.mockReturnValue(mockDispatch);
101101
mockUseAssistantAction.mockClear();
@@ -448,7 +448,7 @@ describe('usePPLExecuteQueryAction', () => {
448448
await resultPromise;
449449

450450
// Verify that defaultPrepareQueryString was called with the correct query object
451-
expect(mockDefaultPrepareQueryString).toHaveBeenCalledWith({
451+
expect(mockPrepareQueryForLanguage).toHaveBeenCalledWith({
452452
dataSource: 'test-source',
453453
timeRange: { from: 'now-1h', to: 'now' },
454454
query: 'source=logs | where status="error"',

src/plugins/explore/public/components/query_panel/actions/ppl_execute_query_action.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { useOpenSearchDashboards } from '../../../../../opensearch_dashboards_re
88
import { ExploreServices } from '../../../types';
99
import { loadQueryActionCreator } from '../../../application/utils/state_management/actions/query_editor/load_query';
1010
import { useSetEditorTextWithQuery } from '../../../application/hooks';
11-
import { defaultPrepareQueryString } from '../../../application/utils/state_management/actions/query_actions';
1211
import { QueryExecutionStatus } from '../../../application/utils/state_management/types';
12+
import { prepareQueryForLanguage } from '../../../application/utils/languages';
1313

1414
export const PPL_QUERY_EXECUTION_TIMEOUT_MS = 10000;
1515
export const PPL_QUERY_POLL_INTERVAL_MS = 1000;
@@ -145,7 +145,7 @@ export function usePPLExecuteQueryAction(
145145
...query,
146146
query: args.query,
147147
};
148-
const cacheKey = defaultPrepareQueryString(queryObject);
148+
const cacheKey = prepareQueryForLanguage(queryObject).query;
149149

150150
// Use loadQueryActionCreator which updates the editor and executes the query
151151
// This follows the same pattern as Recent Queries

0 commit comments

Comments
 (0)