-
Notifications
You must be signed in to change notification settings - Fork 891
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
[Discover] notify user about field_type_tolerance for SQL/PPL in query footer #8702
Closed
joshuali925
wants to merge
3
commits into
opensearch-project:main
from
joshuali925:field_type_tolerance
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feat: | ||
- Notify user about field_type_tolerance for SQL/PPL in discover query footer ([#8702](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8702)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
*/ | ||
|
||
@import "./query_assist"; | ||
@import "./query_editor_extensions"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/plugins/query_enhancements/public/query_editor_extensions/_index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
.queryEnhancements { | ||
.sqlArrayInfoPopoverText { | ||
width: 280px; | ||
|
||
p { | ||
// align with text after icon + gutter | ||
margin-left: calc($euiSizeM + $euiSizeM); | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...query_enhancements/public/query_editor_extensions/field_type_tolerance_info_icon.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import '@testing-library/jest-dom'; | ||
import { fireEvent, render, waitFor } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { IntlProvider } from 'react-intl'; | ||
import { coreMock } from '../../../../core/public/mocks'; | ||
import { DEFAULT_DATA } from '../../../data/common'; | ||
import { dataPluginMock } from '../../../data/public/mocks'; | ||
import { useOpenSearchDashboards } from '../../../opensearch_dashboards_react/public'; | ||
import { FieldTypeToleranceInfoIcon } from './field_type_tolerance_info_icon'; | ||
|
||
jest.mock('../../../opensearch_dashboards_react/public', () => ({ | ||
useOpenSearchDashboards: jest.fn(), | ||
})); | ||
|
||
const coreSetupMock = coreMock.createSetup(); | ||
const dataMock = dataPluginMock.createSetupContract(); | ||
const getQueryMock = dataMock.query.queryString.getQuery as jest.Mock; | ||
const startMock = coreMock.createStart(); | ||
|
||
describe('FieldTypeToleranceInfoIcon', () => { | ||
const renderComponent = () => | ||
render( | ||
<IntlProvider locale="en"> | ||
<FieldTypeToleranceInfoIcon core={coreSetupMock} data={dataMock} /> | ||
</IntlProvider> | ||
); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
localStorage.clear(); | ||
jest.useFakeTimers(); | ||
(useOpenSearchDashboards as jest.Mock).mockReturnValue({ services: startMock }); | ||
}); | ||
|
||
it('should render null when datasource is not OpenSearch', async () => { | ||
getQueryMock.mockReturnValueOnce({ dataset: { dataSource: { type: 'S3' } } }); | ||
const { container } = renderComponent(); | ||
jest.runAllTimers(); | ||
|
||
await waitFor(() => expect(coreSetupMock.http.post).not.toHaveBeenCalled()); | ||
expect(container).toBeEmptyDOMElement(); | ||
}); | ||
|
||
it('should render null when field type tolerance is enabled', async () => { | ||
coreSetupMock.http.post.mockResolvedValueOnce({ | ||
persistent: { 'plugins.query.field_type_tolerance': 'true' }, | ||
transient: {}, | ||
}); | ||
getQueryMock.mockReturnValueOnce({ | ||
dataset: { dataSource: { type: DEFAULT_DATA.SOURCE_TYPES.OPENSEARCH } }, | ||
}); | ||
|
||
const { container } = renderComponent(); | ||
jest.runAllTimers(); | ||
|
||
await waitFor(() => expect(coreSetupMock.http.post).toHaveBeenCalled()); | ||
expect(container).toBeEmptyDOMElement(); | ||
}); | ||
|
||
it('should show popover if field type tolerance is disabled', async () => { | ||
coreSetupMock.http.post.mockResolvedValueOnce({ | ||
persistent: { 'plugins.query.field_type_tolerance': 'false' }, | ||
transient: {}, | ||
}); | ||
getQueryMock.mockReturnValueOnce({ | ||
dataset: { dataSource: { type: DEFAULT_DATA.SOURCE_TYPES.OPENSEARCH } }, | ||
}); | ||
|
||
const { getByRole, queryByText } = renderComponent(); | ||
jest.runAllTimers(); | ||
|
||
await waitFor(() => expect(getByRole('button')).toBeInTheDocument()); | ||
fireEvent.click(getByRole('button')); | ||
expect(queryByText('No array datatype support')).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why cant we reuse the editor prop or pass it directly in the editor?