diff --git a/common/constants/data_sources.ts b/common/constants/data_sources.ts index e02243d56..ad36822b4 100644 --- a/common/constants/data_sources.ts +++ b/common/constants/data_sources.ts @@ -39,7 +39,8 @@ export const ACCELERATION_INDEX_NAME_REGEX = /^[a-z0-9_]+$/; export const ACCELERATION_S3_URL_REGEX = /^(s3|s3a):\/\/[a-zA-Z0-9.\-]+/; export const SPARK_HIVE_TABLE_REGEX = /Provider:\s*hive/; export const SANITIZE_QUERY_REGEX = /\s+/g; -export const TIMESTAMP_DATATYPE = 'timestamp'; +export const SPARK_TIMESTAMP_DATATYPE = 'timestamp'; +export const SPARK_STRING_DATATYPE = 'string'; export const ACCELERATION_INDEX_TYPES = [ { label: 'Skipping Index', value: 'skipping' }, @@ -49,6 +50,8 @@ export const ACCELERATION_INDEX_TYPES = [ export const ACC_INDEX_TYPE_DOCUMENTATION_URL = 'https://github.com/opensearch-project/opensearch-spark/blob/main/docs/index.md'; +export const ACC_CHECKPOINT_DOCUMENTATION_URL = + 'https://github.com/opensearch-project/opensearch-spark/blob/main/docs/index.md#create-index-options'; export const ACCELERATION_INDEX_NAME_INFO = `All OpenSearch acceleration indices have a naming format of pattern: \`prefix__suffix\`. They share a common prefix structure, which is \`flint____\`. Additionally, they may have a suffix that varies based on the index type. ##### Skipping Index diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/__tests__/__snapshots__/create_acceleration.test.tsx.snap b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/__tests__/__snapshots__/create_acceleration.test.tsx.snap index 5e0c5a775..d5b4b8e5c 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/__tests__/__snapshots__/create_acceleration.test.tsx.snap +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/__tests__/__snapshots__/create_acceleration.test.tsx.snap @@ -655,6 +655,39 @@ Array [ > Checkpoint location + +
- Please add fields + You have no definitions defined.
@@ -2081,6 +2114,40 @@ Array [ > Checkpoint location + +
+ + Learn more + + + + + (opens in a new tab or window) + + +
- Please add fields + You have no definitions defined.
diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration.tsx b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration.tsx index c6f3ddbb4..da0dc8707 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration.tsx +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration.tsx @@ -28,6 +28,7 @@ import { DirectQueryLoadingStatus } from '../../../../../../../../common/types/e import { useLoadTableColumnsToCache } from '../../../../../../../framework/catalog_cache/cache_loader'; import { CatalogCacheManager } from '../../../../../../../framework/catalog_cache/cache_manager'; import { coreRefs } from '../../../../../../../framework/core_refs'; +import { useToast } from '../../../../../../common/toast'; import { IndexAdvancedSettings } from '../selectors/index_advanced_settings'; import { IndexSettingOptions } from '../selectors/index_setting_options'; import { IndexTypeSelector } from '../selectors/index_type_selector'; @@ -43,6 +44,7 @@ export interface CreateAccelerationProps { resetFlyout: () => void; databaseName?: string; tableName?: string; + refreshHandler?: () => void; } export const CreateAcceleration = ({ @@ -51,6 +53,7 @@ export const CreateAcceleration = ({ databaseName, tableName, }: CreateAccelerationProps) => { + const { setToast } = useToast(); const http = coreRefs!.http; const [accelerationFormData, setAccelerationFormData] = useState({ dataSource: selectedDatasource, @@ -135,13 +138,17 @@ export const CreateAcceleration = ({ stopLoadingTableFields(); if (dataTable !== '') { setTableFieldsLoading(true); - const cachedTable = CatalogCacheManager.getTable(dataSource, database, dataTable); - - if (cachedTable.columns) { - loadColumnsToAccelerationForm(cachedTable); - setTableFieldsLoading(false); - } else { - startLoading(dataSource, database, dataTable); + try { + const cachedTable = CatalogCacheManager.getTable(dataSource, database, dataTable); + if (cachedTable.columns) { + loadColumnsToAccelerationForm(cachedTable); + setTableFieldsLoading(false); + } else { + startLoading(dataSource, database, dataTable); + } + } catch (error) { + setToast('Your cache is outdated, refresh databases and tables', 'warning'); + console.error(error); } } }; @@ -159,11 +166,18 @@ export const CreateAcceleration = ({ useEffect(() => { const status = loadStatus.toLowerCase(); if (status === DirectQueryLoadingStatus.SUCCESS) { - const cachedTable = CatalogCacheManager.getTable( - accelerationFormData.dataSource, - accelerationFormData.database, - accelerationFormData.dataTable - ); + let cachedTable = {} as CachedTable; + try { + cachedTable = CatalogCacheManager.getTable( + accelerationFormData.dataSource, + accelerationFormData.database, + accelerationFormData.dataTable + ); + } catch (error) { + setToast('Your cache is outdated, refresh databases and tables', 'warning'); + console.error(error); + } + loadColumnsToAccelerationForm(cachedTable); setTableFieldsLoading(false); } else if ( diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration_button.tsx b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration_button.tsx index b1429515c..8a8724827 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration_button.tsx +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/create/create_acceleration_button.tsx @@ -59,13 +59,14 @@ export const CreateAccelerationButton = ({ status === DirectQueryLoadingStatus.CANCELED ) { setIsLoading(false); - setToast('Create acceleration query failed', 'success'); } }, [directqueryLoadStatus]); - return ( + const createAccelerationBtn = ( - Create acceleration + {isLoading ? 'Creating acceleration' : 'Create acceleration'} ); + + return createAccelerationBtn; }; diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/__tests__/__snapshots__/index_setting_options.test.tsx.snap b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/__tests__/__snapshots__/index_setting_options.test.tsx.snap index e38d3bce5..d4b97ea70 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/__tests__/__snapshots__/index_setting_options.test.tsx.snap +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/__tests__/__snapshots__/index_setting_options.test.tsx.snap @@ -124,6 +124,40 @@ Array [ > Checkpoint location + +
+ + Learn more + + + + + (opens in a new tab or window) + + +
Checkpoint location + +
Checkpoint location + +
+ + Learn more + + + } > - Continue in Query Workbench + Edit in Query Workbench ) : ( <> diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/source_selector.tsx b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/source_selector.tsx index f1dac3eac..d086b0c28 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/source_selector.tsx +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/source_selector.tsx @@ -20,12 +20,13 @@ import React, { useEffect, useState } from 'react'; import { CoreStart } from '../../../../../../../../../../src/core/public'; import { DATACONNECTIONS_BASE } from '../../../../../../../../common/constants/shared'; import { + CachedDatabase, CachedDataSourceStatus, CreateAccelerationForm, } from '../../../../../../../../common/types/data_connections'; import { CatalogCacheManager } from '../../../../../../../framework/catalog_cache/cache_manager'; import { useToast } from '../../../../../../common/toast'; -import { hasError, validateDataTable, validateDatabase } from '../create/utils'; +import { hasError, validateDatabase, validateDataTable } from '../create/utils'; import { SelectorLoadDatabases } from './selector_helpers/load_databases'; import { SelectorLoadObjects } from './selector_helpers/load_objects'; @@ -111,18 +112,25 @@ export const AccelerationDataSourceSelector = ({ const loadTables = () => { if (selectedDatabase.length > 0) { - const dbCache = CatalogCacheManager.getDatabase( - accelerationFormData.dataSource, - accelerationFormData.database - ); - if (dbCache.status === CachedDataSourceStatus.Updated && dbCache.tables.length > 0) { - const tableLabels = dbCache.tables.map((tb) => ({ label: tb.name })); - setTables(tableLabels); - } else if ( - (dbCache.status === CachedDataSourceStatus.Updated && dbCache.tables.length === 0) || - dbCache.status === CachedDataSourceStatus.Empty - ) { + let dbCache = {} as CachedDatabase; + try { + dbCache = CatalogCacheManager.getDatabase( + accelerationFormData.dataSource, + accelerationFormData.database + ); + if (dbCache.status === CachedDataSourceStatus.Updated && dbCache.tables.length > 0) { + const tableLabels = dbCache.tables.map((tb) => ({ label: tb.name })); + setTables(tableLabels); + } else if ( + (dbCache.status === CachedDataSourceStatus.Updated && dbCache.tables.length === 0) || + dbCache.status === CachedDataSourceStatus.Empty + ) { + setTables([]); + } + } catch (error) { setTables([]); + setToast('Your cache is outdated, refresh databases and tables', 'warning'); + console.error(error); } setSelectedTable([]); setAccelerationFormData({ ...accelerationFormData, dataTable: '' }); diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/visual_editors/__tests__/__snapshots__/query_visual_editor.test.tsx.snap b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/visual_editors/__tests__/__snapshots__/query_visual_editor.test.tsx.snap index 85e73b484..628a20254 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/visual_editors/__tests__/__snapshots__/query_visual_editor.test.tsx.snap +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/visual_editors/__tests__/__snapshots__/query_visual_editor.test.tsx.snap @@ -241,7 +241,7 @@ Array [ - Please add fields + You have no definitions defined.
@@ -728,12 +728,6 @@ Array [ - -