From 0198fa7fc20ff5dee7caf75b5fef6ba6818f4508 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:23:17 -0700 Subject: [PATCH] Make checkpoint mandatory, add watermark delay, minor UI fixes (#173) (#175) * make checkpoint mandatory * update timestamp type for MV * add watermark and datasource empty check * minor fixes * updates datasources acc * adding tests for watermark, minor fixes * update acc index flyout * update docs links --------- (cherry picked from commit a5aa2d2112973b979750c5416801517c35b81ad9) Signed-off-by: Shenoy Pratik Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- common/constants/index.ts | 1 + common/types/index.ts | 20 +- common/utils/async_query_helpers.ts | 2 +- .../Main/__snapshots__/main.test.tsx.snap | 28 +- public/components/Main/main.tsx | 24 +- public/components/SQLPage/DataSelect.tsx | 6 +- .../acceleration_index_flyout.test.tsx.snap | 1824 +++++++++++++++++ .../acceleration_index_flyout.test.tsx | 109 + .../SQLPage/acceleration_index_flyout.tsx | 81 +- public/components/SQLPage/table_view.test.tsx | 5 - public/components/SQLPage/table_view.tsx | 47 +- .../create_acceleration.test.tsx.snap | 4 +- .../create/__tests__/utils.test.tsx | 29 +- .../create/create_acceleration.tsx | 5 + .../components/acceleration/create/utils.tsx | 22 +- .../index_setting_options.test.tsx.snap | 6 +- .../selectors/index_setting_options.tsx | 65 +- .../selectors/index_type_selector.tsx | 31 +- .../selectors/source_selector.tsx | 85 +- .../__tests__/query_builder.test.tsx | 7 + .../group_by_tumble_expression.tsx | 4 +- .../visual_editors/query_builder.tsx | 11 +- test/mocks/accelerationMock.ts | 35 + 23 files changed, 2292 insertions(+), 159 deletions(-) create mode 100644 public/components/SQLPage/__tests__/__snapshots__/acceleration_index_flyout.test.tsx.snap create mode 100644 public/components/SQLPage/__tests__/acceleration_index_flyout.test.tsx diff --git a/common/constants/index.ts b/common/constants/index.ts index 0f78c810..6e88cb94 100644 --- a/common/constants/index.ts +++ b/common/constants/index.ts @@ -89,6 +89,7 @@ export const ACCELERATION_INDEX_NAME_INFO = `All OpenSearch acceleration indices - All user given index names must be in lowercase letters. Index name cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \, |, ?, #, >, or < are not allowed. `; +export const TIMESTAMP_DATATYPE = 'timestamp'; export const FETCH_OPENSEARCH_INDICES_PATH = '/api/sql_console/sqlquery'; export const POLL_INTERVAL_MS = 2000; export const ASYNC_QUERY_ENDPOINT = '/api/spark_sql_console'; diff --git a/common/types/index.ts b/common/types/index.ts index 17208cc3..ad06694d 100644 --- a/common/types/index.ts +++ b/common/types/index.ts @@ -32,6 +32,11 @@ export interface RefreshIntervalType { refreshInterval: string; } +export interface watermarkDelayType { + delayWindow: number; + delayInterval: string; +} + export type AccelerationIndexType = 'skipping' | 'covering' | 'materialized'; export interface GroupByTumbleType { @@ -57,6 +62,7 @@ export interface FormErrorsType { replicaShardsError: string[]; refreshIntervalError: string[]; checkpointLocationError: string[]; + watermarkDelayError: string[]; } export type AccelerationRefreshType = 'auto' | 'interval' | 'manual'; @@ -75,22 +81,30 @@ export interface CreateAccelerationForm { replicaShardsCount: number; refreshType: AccelerationRefreshType; checkpointLocation: string | undefined; + watermarkDelay: watermarkDelayType; refreshIntervalOptions: RefreshIntervalType; formErrors: FormErrorsType; } export type AsyncQueryLoadingStatus = 'SUCCESS' | 'FAILED' | 'RUNNING' | 'SCHEDULED' | 'CANCELLED'; -export type TreeItemType = 'covering_index' | 'skipping_index' | 'table' | 'database' | 'materialized_view' | 'Load Materialized View' | 'badge' +export type TreeItemType = + | 'covering_index' + | 'skipping_index' + | 'table' + | 'database' + | 'materialized_view' + | 'Load Materialized View' + | 'badge'; export interface TreeItem { name: string; type: TreeItemType; isExpanded: boolean; values?: TreeItem[]; - isLoading?: boolean + isLoading?: boolean; } -export interface isLoading { +export interface DatasourceTreeLoading { flag: boolean; status: string; } diff --git a/common/utils/async_query_helpers.ts b/common/utils/async_query_helpers.ts index 3731859e..ca20fd79 100644 --- a/common/utils/async_query_helpers.ts +++ b/common/utils/async_query_helpers.ts @@ -47,7 +47,7 @@ export const pollQueryStatus = (id: string, http: CoreStart['http'], callback) = status === 'scheduled' || status === 'waiting' ) { - callback({status: status}) + callback({ status: status }); setTimeout(() => pollQueryStatus(id, http, callback), POLL_INTERVAL_MS); } else if (status === 'failed') { callback({ status: 'FAILED', results: [] }); diff --git a/public/components/Main/__snapshots__/main.test.tsx.snap b/public/components/Main/__snapshots__/main.test.tsx.snap index 3b7c236c..5627180f 100644 --- a/public/components/Main/__snapshots__/main.test.tsx.snap +++ b/public/components/Main/__snapshots__/main.test.tsx.snap @@ -155,7 +155,7 @@ exports[`
spec click clear button 1`] = ` > @@ -193,7 +193,7 @@ exports[`
spec click clear button 1`] = ` >
spec click run button, and response causes an error 1`] = ` > @@ -750,7 +750,7 @@ exports[`
spec click run button, and response causes an error 1`] = ` >
spec click run button, and response is not ok 1`] = ` > @@ -1307,7 +1307,7 @@ exports[`
spec click run button, and response is not ok 1`] = ` >
spec click run button, and response is ok 1`] = ` > @@ -1864,7 +1864,7 @@ exports[`
spec click run button, and response is ok 1`] = ` >
spec click run button, response fills null and missing values > @@ -2505,7 +2505,7 @@ exports[`
spec click run button, response fills null and missing values >
spec click translation button, and response is ok 1`] = ` > @@ -3145,7 +3145,7 @@ exports[`
spec click translation button, and response is ok 1`] = ` >
spec renders the component 1`] = ` > @@ -3693,7 +3693,7 @@ exports[`
spec renders the component 1`] = ` >
{ refreshTree: !this.state.refreshTree, }); }; - + setIsAccelerationFlyoutOpened = (value: boolean) => { this.setState({ isAccelerationFlyoutOpened: value, @@ -863,7 +863,7 @@ export class Main extends React.Component { setIsAccelerationFlyoutOpened={this.setIsAccelerationFlyoutOpened} /> ); - link = 'https://opensearch.org/docs/latest/search-plugins/sql/index/'; + link = 'https://opensearch.org/docs/latest/search-plugins/sql/sql/index/'; linkTitle = 'SQL documentation'; } else { page = ( @@ -881,7 +881,7 @@ export class Main extends React.Component { asyncLoading={this.state.asyncLoading} /> ); - link = 'https://opensearch.org/docs/latest/observability-plugin/ppl/index/'; + link = 'https://opensearch.org/docs/latest/search-plugins/sql/ppl/index/'; linkTitle = 'PPL documentation'; } @@ -957,18 +957,26 @@ export class Main extends React.Component { {this.state.language === 'SQL' && ( - - + + - + diff --git a/public/components/SQLPage/DataSelect.tsx b/public/components/SQLPage/DataSelect.tsx index e2448b69..416c1025 100644 --- a/public/components/SQLPage/DataSelect.tsx +++ b/public/components/SQLPage/DataSelect.tsx @@ -74,8 +74,10 @@ export const DataSelect = ({ http, onSelect, urlDataSource, asyncLoading }: Cust }, []); const handleSelectionChange = (selectedItems: any[]) => { - setSelectedOptions(selectedItems); - onSelect(selectedItems); + if (selectedItems.length > 0) { + setSelectedOptions(selectedItems); + onSelect(selectedItems); + } }; return ( diff --git a/public/components/SQLPage/__tests__/__snapshots__/acceleration_index_flyout.test.tsx.snap b/public/components/SQLPage/__tests__/__snapshots__/acceleration_index_flyout.test.tsx.snap new file mode 100644 index 00000000..5f635691 --- /dev/null +++ b/public/components/SQLPage/__tests__/__snapshots__/acceleration_index_flyout.test.tsx.snap @@ -0,0 +1,1824 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Acceleration index flyout renders acceleration flyout with covering index 1`] = ` +Array [ + "", + +