From da998e6a89a35eb0f898a6a7ead4f4b9174dcfee Mon Sep 17 00:00:00 2001 From: Eric Wei Date: Mon, 13 Nov 2023 11:15:03 -0800 Subject: [PATCH] Revert "Add materlized views, manual refresh option and minor fixes (#159) (#161)" (#212) This reverts commit 88970fbf8d1386bcb46d0a4adca69416715d0bd2. Signed-off-by: Eric --- common/constants/index.ts | 8 +- common/types/index.ts | 6 +- public/components/Main/main.tsx | 14 +-- public/components/SQLPage/SQLPage.tsx | 18 +--- .../create_acceleration.test.tsx.snap | 65 +++----------- .../create_acceleration_header.test.tsx.snap | 2 +- .../index_setting_options.test.tsx.snap | 87 +++---------------- .../index_type_selector.test.tsx.snap | 4 +- .../source_selector.test.tsx.snap | 4 +- .../selectors/index_setting_options.tsx | 83 +++++++----------- .../selectors/source_selector.tsx | 2 +- .../__tests__/query_builder.test.tsx | 7 -- .../visual_editors/query_builder.tsx | 8 +- test/mocks/accelerationMock.ts | 20 +---- 14 files changed, 77 insertions(+), 251 deletions(-) diff --git a/common/constants/index.ts b/common/constants/index.ts index ea25495a..c7ed1d43 100644 --- a/common/constants/index.ts +++ b/common/constants/index.ts @@ -5,10 +5,8 @@ export const PLUGIN_ID = 'queryWorkbenchDashboards'; export const PLUGIN_NAME = 'Query Workbench'; -export const OPENSEARCH_ACC_DOCUMENTATION_URL = - 'https://opensearch.org/docs/latest/dashboards/management/accelerate-external-data/'; -export const ACC_INDEX_TYPE_DOCUMENTATION_URL = - 'https://github.com/opensearch-project/opensearch-spark/blob/main/docs/index.md'; +export const OPENSEARCH_ACC_DOCUMENTATION_URL = 'https://opensearch.org/docs/latest'; +export const ACC_INDEX_TYPE_DOCUMENTATION_URL = 'https://opensearch.org/docs/latest'; export const SKIPPING_INDEX = `skipping_index`; export const ON_LOAD_QUERY = `SHOW tables LIKE '%';`; @@ -39,7 +37,7 @@ OPTIONS ( export const ACCELERATION_INDEX_TYPES = [ { label: 'Skipping Index', value: 'skipping' }, { label: 'Covering Index', value: 'covering' }, - { label: 'Materialized View', value: 'materialized' }, + // { label: 'Materialized View', value: 'materialized' }, Hidden Option -> Until opensearch-spark feature is ready ]; export const ACCELERATION_AGGREGRATION_FUNCTIONS = [ diff --git a/common/types/index.ts b/common/types/index.ts index e669ce49..c96bb147 100644 --- a/common/types/index.ts +++ b/common/types/index.ts @@ -59,8 +59,6 @@ export interface FormErrorsType { checkpointLocationError: string[]; } -export type AccelerationRefreshType = 'auto' | 'interval' | 'manual'; - export interface CreateAccelerationForm { dataSource: string; database: string; @@ -73,10 +71,10 @@ export interface CreateAccelerationForm { accelerationIndexName: string; primaryShardsCount: number; replicaShardsCount: number; - refreshType: AccelerationRefreshType; + refreshType: 'interval' | 'auto'; checkpointLocation: string | undefined; refreshIntervalOptions: RefreshIntervalType; formErrors: FormErrorsType; } -export type AsyncQueryLoadingStatus = 'SUCCESS' | 'FAILED' | 'RUNNING' | 'SCHEDULED' | 'CANCELED'; +export type AsyncQueryLoadingStatus = "SUCCESS" | "FAILED" | "RUNNING" | "SCHEDULED" | "CANCELED" \ No newline at end of file diff --git a/public/components/Main/main.tsx b/public/components/Main/main.tsx index ae28ff67..86f24463 100644 --- a/public/components/Main/main.tsx +++ b/public/components/Main/main.tsx @@ -109,7 +109,6 @@ interface MainState { asyncLoading: boolean; asyncLoadingStatus: AsyncQueryLoadingStatus; asyncJobId: string; - isAccelerationFlyoutOpened: boolean; } const SUCCESS_MESSAGE = 'Success'; @@ -247,7 +246,6 @@ export class Main extends React.Component { asyncLoading: false, asyncLoadingStatus: 'SUCCESS', asyncJobId: '', - isAccelerationFlyoutOpened: false, }; this.httpClient = this.props.httpClient; this.updateSQLQueries = _.debounce(this.updateSQLQueries, 250).bind(this); @@ -791,7 +789,7 @@ export class Main extends React.Component { }); } - handleDataSelect = (selectedItems: EuiComboBoxOptionOption[]) => { + handleDataSelect = (selectedItems: []) => { if (selectedItems[0].label !== 'OpenSearch' && this.state.language === 'SQL') { this.updateSQLQueries(''); } @@ -800,12 +798,6 @@ export class Main extends React.Component { }); }; - setIsAccelerationFlyoutOpened = (value: boolean) => { - this.setState({ - isAccelerationFlyoutOpened: value, - }); - }; - render() { let page; let link; @@ -827,10 +819,6 @@ export class Main extends React.Component { updateSQLQueries={this.updateSQLQueries} selectedDatasource={this.state.selectedDatasource} asyncLoading={this.state.asyncLoading} - openAccelerationFlyout={ - this.props.isAccelerationFlyoutOpen && !this.state.isAccelerationFlyoutOpened - } - setIsAccelerationFlyoutOpened={this.setIsAccelerationFlyoutOpened} /> ); link = 'https://opensearch.org/docs/latest/search-plugins/sql/index/'; diff --git a/public/components/SQLPage/SQLPage.tsx b/public/components/SQLPage/SQLPage.tsx index 29311eb7..b70029e6 100644 --- a/public/components/SQLPage/SQLPage.tsx +++ b/public/components/SQLPage/SQLPage.tsx @@ -37,8 +37,6 @@ interface SQLPageProps { sqlTranslations: ResponseDetail[]; selectedDatasource: EuiComboBoxOptionOption[]; asyncLoading: boolean; - openAccelerationFlyout: boolean; - setIsAccelerationFlyoutOpened: (value: boolean) => void; } interface SQLPageState { @@ -82,21 +80,6 @@ export class SQLPage extends React.Component { }); }; - componentDidUpdate(prevProps: SQLPageProps) { - const { selectedDatasource, openAccelerationFlyout } = this.props; - const prevDataSource = prevProps.selectedDatasource[0].label; - const currentDataSource = selectedDatasource[0].label; - - if ( - currentDataSource !== prevDataSource && - currentDataSource !== 'OpenSearch' && - openAccelerationFlyout - ) { - this.setAccelerationFlyout(); - this.props.setIsAccelerationFlyoutOpened(true); - } - } - render() { const closeModal = () => this.setIsModalVisible(false); const showModal = () => this.setIsModalVisible(true); @@ -204,6 +187,7 @@ export class SQLPage extends React.Component { this.props.selectedDatasource[0].label !== 'OpenSearch' && ( @@ -132,7 +132,7 @@ Array [
- Select the data source to accelerate data from. External data sources may take time to load. + Select data connection where the data you want to accelerate resides.
- Auto refresh by interval - -
-
- -
-
@@ -718,7 +698,7 @@ Array [ class="euiFormHelpText euiFormRow__text" id="some_html_id-help-0" > - Specify how often the index should refresh, which publishes the most recent changes and make them available for search. + Specify how often the index should refresh, which publishes the most recent changes and make them available for search. Default is set to auto refresh when data at the source changes. @@ -1201,7 +1181,7 @@ Array [
@@ -1263,7 +1243,7 @@ Array [
- Select the data source to accelerate data from. External data sources may take time to load. + Select data connection where the data you want to accelerate resides.
,
- Auto refresh by interval - -
-
- -
-
@@ -1970,7 +1929,7 @@ Array [ className="euiFormHelpText euiFormRow__text" id="some_html_id-help-0" > - Specify how often the index should refresh, which publishes the most recent changes and make them available for search. + Specify how often the index should refresh, which publishes the most recent changes and make them available for search. Default is set to auto refresh when data at the source changes. , diff --git a/public/components/acceleration/create/__tests__/__snapshots__/create_acceleration_header.test.tsx.snap b/public/components/acceleration/create/__tests__/__snapshots__/create_acceleration_header.test.tsx.snap index e722b161..1c099f4b 100644 --- a/public/components/acceleration/create/__tests__/__snapshots__/create_acceleration_header.test.tsx.snap +++ b/public/components/acceleration/create/__tests__/__snapshots__/create_acceleration_header.test.tsx.snap @@ -29,7 +29,7 @@ exports[`Acceleration header renders acceleration flyout header 1`] = `
diff --git a/public/components/acceleration/selectors/__tests__/__snapshots__/index_setting_options.test.tsx.snap b/public/components/acceleration/selectors/__tests__/__snapshots__/index_setting_options.test.tsx.snap index ea5c51e3..49459fd5 100644 --- a/public/components/acceleration/selectors/__tests__/__snapshots__/index_setting_options.test.tsx.snap +++ b/public/components/acceleration/selectors/__tests__/__snapshots__/index_setting_options.test.tsx.snap @@ -32,7 +32,7 @@ Array [ > @@ -297,7 +297,7 @@ Array [ className="euiRadio__label" htmlFor="refresh-option-1" > - Auto refresh + Auto Refresh
- Auto refresh by interval - -
-
- -
-
@@ -347,7 +326,7 @@ Array [ className="euiFormHelpText euiFormRow__text" id="some_html_id-help-0" > - Specify how often the index should refresh, which publishes the most recent changes and make them available for search. + Specify how often the index should refresh, which publishes the most recent changes and make them available for search. Default is set to auto refresh when data at the source changes. , @@ -432,7 +411,7 @@ Array [ >
@@ -705,7 +684,7 @@ Array [ className="euiRadio__label" htmlFor="refresh-option-1" > - Auto refresh + Auto Refresh
- Auto refresh by interval - -
-
- -
-
@@ -755,7 +713,7 @@ Array [ className="euiFormHelpText euiFormRow__text" id="some_html_id-help-0" > - Specify how often the index should refresh, which publishes the most recent changes and make them available for search. + Specify how often the index should refresh, which publishes the most recent changes and make them available for search. Default is set to auto refresh when data at the source changes. , @@ -840,7 +798,7 @@ Array [ >
@@ -1113,7 +1071,7 @@ Array [ className="euiRadio__label" htmlFor="refresh-option-1" > - Auto refresh + Auto Refresh
- Auto refresh by interval - -
-
- -
-
@@ -1163,7 +1100,7 @@ Array [ className="euiFormHelpText euiFormRow__text" id="some_html_id-help-0" > - Specify how often the index should refresh, which publishes the most recent changes and make them available for search. + Specify how often the index should refresh, which publishes the most recent changes and make them available for search. Default is set to auto refresh when data at the source changes. , diff --git a/public/components/acceleration/selectors/__tests__/__snapshots__/index_type_selector.test.tsx.snap b/public/components/acceleration/selectors/__tests__/__snapshots__/index_type_selector.test.tsx.snap index aa035061..6a41fd85 100644 --- a/public/components/acceleration/selectors/__tests__/__snapshots__/index_type_selector.test.tsx.snap +++ b/public/components/acceleration/selectors/__tests__/__snapshots__/index_type_selector.test.tsx.snap @@ -20,7 +20,7 @@ exports[`Index type selector components renders type selector with default optio >
@@ -170,7 +170,7 @@ exports[`Index type selector components renders type selector with different opt > diff --git a/public/components/acceleration/selectors/__tests__/__snapshots__/source_selector.test.tsx.snap b/public/components/acceleration/selectors/__tests__/__snapshots__/source_selector.test.tsx.snap index 23129c8e..47b7da24 100644 --- a/public/components/acceleration/selectors/__tests__/__snapshots__/source_selector.test.tsx.snap +++ b/public/components/acceleration/selectors/__tests__/__snapshots__/source_selector.test.tsx.snap @@ -19,7 +19,7 @@ Array [
- Select the data source to accelerate data from. External data sources may take time to load. + Select data connection where the data you want to accelerate resides.
,
- Select the data source to accelerate data from. External data sources may take time to load. + Select data connection where the data you want to accelerate resides.
,
{ const autoRefreshId = 'refresh-option-1'; const intervalRefreshId = 'refresh-option-2'; - const manualRefreshId = 'refresh-option-3'; const refreshOptions = [ { id: autoRefreshId, - label: 'Auto refresh', + label: 'Auto Refresh', }, { id: intervalRefreshId, - label: 'Auto refresh by interval', - }, - { - id: manualRefreshId, - label: 'Manual refresh', + label: 'Refresh by interval', }, ]; @@ -75,21 +70,9 @@ export const IndexSettingOptions = ({ }; const onChangeRefreshType = (optionId: React.SetStateAction) => { - let refreshOption: AccelerationRefreshType = 'auto'; - switch (optionId) { - case autoRefreshId: - refreshOption = 'auto'; - break; - case intervalRefreshId: - refreshOption = 'interval'; - break; - case manualRefreshId: - refreshOption = 'manual'; - break; - } setAccelerationFormData({ ...accelerationFormData, - refreshType: refreshOption, + refreshType: optionId === autoRefreshId ? 'auto' : 'interval', }); setRefreshTypeSelected(optionId); }; @@ -183,7 +166,7 @@ export const IndexSettingOptions = ({ )} - {refreshTypeSelected !== manualRefreshId && ( - + - { - setAccelerationFormData( - producer((accData) => { - accData.formErrors.checkpointLocationError = validateCheckpointLocation( - accData.accelerationIndexType, - e.target.value - ); - }) - ); - }} - /> - - )} + onBlur={(e) => { + setAccelerationFormData( + producer((accData) => { + accData.formErrors.checkpointLocationError = validateCheckpointLocation( + accData.accelerationIndexType, + e.target.value + ); + }) + ); + }} + /> + ); }; diff --git a/public/components/acceleration/selectors/source_selector.tsx b/public/components/acceleration/selectors/source_selector.tsx index d558e1dd..ea365876 100644 --- a/public/components/acceleration/selectors/source_selector.tsx +++ b/public/components/acceleration/selectors/source_selector.tsx @@ -114,7 +114,7 @@ export const AccelerationDataSourceSelector = ({ - Select the data source to accelerate data from. External data sources may take time to load. + Select data connection where the data you want to accelerate resides. { expect(indexOptions).toEqual(indexOptionsMockResult3); }); - it('should build index options with manual refresh', () => { - const indexOptions = buildIndexOptions(indexOptionsMock4); - expect(indexOptions).toEqual(indexOptionsMockResult4); - }); - describe('skippingIndexQueryBuilder', () => { it('should build skipping index query as expected with interval refresh', () => { const result = skippingIndexQueryBuilder(skippingIndexBuilderMock1); diff --git a/public/components/acceleration/visual_editors/query_builder.tsx b/public/components/acceleration/visual_editors/query_builder.tsx index 83f8f7af..b4537f0e 100644 --- a/public/components/acceleration/visual_editors/query_builder.tsx +++ b/public/components/acceleration/visual_editors/query_builder.tsx @@ -27,7 +27,7 @@ export const buildIndexOptions = (accelerationformData: CreateAccelerationForm) ); // Add auto refresh option - indexOptions.push(`auto_refresh = ${['auto', 'interval'].includes(refreshType)}`); + indexOptions.push(`auto_refresh = ${refreshType === 'auto'}`); // Add refresh interval option if (refreshType === 'interval') { @@ -63,7 +63,7 @@ const buildSkippingIndexColumns = (skippingIndexQueryData: SkippingIndexRowType[ * field2 PARTITION, * field3 MIN_MAX, * ) WITH ( - * auto_refresh = true, + * auto_refresh = false, * refresh_interval = '1 minute', * checkpoint_location = 's3://test/', * index_settings = '{"number_of_shards":9,"number_of_replicas":2}' @@ -95,7 +95,7 @@ const buildCoveringIndexColumns = (coveringIndexQueryData: string[]) => { * field2, * field3, * ) WITH ( - * auto_refresh = true, + * auto_refresh = false, * refresh_interval = '1 minute', * checkpoint_location = 's3://test/', * index_settings = '{"number_of_shards":9,"number_of_replicas":2}' @@ -146,7 +146,7 @@ const buildTumbleValue = (GroupByTumbleValue: GroupByTumbleType) => { * sum(field2), * avg(field3) as average * WITH ( - * auto_refresh = true, + * auto_refresh = false, * refresh_interval = '1 minute', * checkpoint_location = 's3://test/', * index_settings = '{"number_of_shards":9,"number_of_replicas":2}' diff --git a/test/mocks/accelerationMock.ts b/test/mocks/accelerationMock.ts index 82d4d1de..3cc0c2ae 100644 --- a/test/mocks/accelerationMock.ts +++ b/test/mocks/accelerationMock.ts @@ -148,7 +148,7 @@ export const indexOptionsMock2: CreateAccelerationForm = { export const indexOptionsMockResult2 = `WITH ( index_settings = '{"number_of_shards":3,"number_of_replicas":2}', -auto_refresh = true, +auto_refresh = false, refresh_interval = '10 minutes' )`; @@ -166,18 +166,6 @@ auto_refresh = true, checkpoint_location = 's3://path/to/checkpoint' )`; -export const indexOptionsMock4: CreateAccelerationForm = { - ...createAccelerationEmptyDataMock, - primaryShardsCount: 3, - replicaShardsCount: 2, - refreshType: 'manual', -}; - -export const indexOptionsMockResult4 = `WITH ( -index_settings = '{"number_of_shards":3,"number_of_replicas":2}', -auto_refresh = false -)`; - export const skippingIndexBuilderMock1: CreateAccelerationForm = { ...createAccelerationEmptyDataMock, dataSource: 'datasource', @@ -220,7 +208,7 @@ ON datasource.database.table ( field3 MIN_MAX ) WITH ( index_settings = '{"number_of_shards":9,"number_of_replicas":2}', -auto_refresh = true, +auto_refresh = false, refresh_interval = '1 minute', checkpoint_location = 's3://test/' )`; @@ -277,7 +265,7 @@ ON datasource.database.table ( field3 ) WITH ( index_settings = '{"number_of_shards":9,"number_of_replicas":2}', -auto_refresh = true, +auto_refresh = false, refresh_interval = '1 minute', checkpoint_location = 's3://test/' )`; @@ -343,7 +331,7 @@ FROM datasource.database.table GROUP BY TUMBLE (timestamp, '1 minute') WITH ( index_settings = '{"number_of_shards":9,"number_of_replicas":2}', -auto_refresh = true, +auto_refresh = false, refresh_interval = '1 minute', checkpoint_location = 's3://test/' )`;