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 507c6fe952..4822300105 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 @@ -24,6 +24,7 @@ import { import { CachedTable, CreateAccelerationForm, + S3GlueProperties, } from '../../../../../../../../common/types/data_connections'; import { DirectQueryLoadingStatus } from '../../../../../../../../common/types/explorer'; import { useLoadTableColumnsToCache } from '../../../../../../../framework/catalog_cache/cache_loader'; @@ -39,6 +40,7 @@ import { QueryVisualEditor } from '../visual_editors/query_visual_editor'; import { CreateAccelerationButton } from './create_acceleration_button'; import { CreateAccelerationHeader } from './create_acceleration_header'; import { hasError } from './utils'; +import { DATACONNECTIONS_BASE } from '../../../../../../../../common/constants/shared'; export interface CreateAccelerationProps { selectedDatasource: string; @@ -59,6 +61,7 @@ export const CreateAcceleration = ({ }: CreateAccelerationProps) => { const { setToast } = useToast(); const http = coreRefs!.http; + const [isS3ConnectionWithLakeFormation, setIsS3ConnectionWithLakeFormation] = useState(false); const [accelerationFormData, setAccelerationFormData] = useState({ dataSource: selectedDatasource, database: databaseName ?? '', @@ -167,6 +170,18 @@ export const CreateAcceleration = ({ } }; + const updateDataSourceConnectionInfo = () => { + coreRefs.http!.get(`${DATACONNECTIONS_BASE}/${selectedDatasource}`).then((data: any) => { + setIsS3ConnectionWithLakeFormation( + !!(data.properties as S3GlueProperties)['glue.lakeformation.enabled'] + ); + }); + }; + + useEffect(() => { + updateDataSourceConnectionInfo(); + }, [selectedDatasource]); + useEffect(() => { if (databaseName !== undefined && tableName !== undefined) { initiateColumnLoad( @@ -236,6 +251,7 @@ export const CreateAcceleration = ({ diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/index_type_selector.tsx b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/index_type_selector.tsx index c169620588..59e5d4cb66 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/index_type_selector.tsx +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/index_type_selector.tsx @@ -4,7 +4,7 @@ */ import { EuiFormRow, EuiLink, EuiSpacer, EuiSuperSelect, EuiText } from '@elastic/eui'; -import React, { Fragment, useEffect, useState } from 'react'; +import React, { Fragment, useEffect, useState, useRef } from 'react'; import { ACCELERATION_DEFUALT_SKIPPING_INDEX_NAME, ACC_INDEX_TYPE_DOCUMENTATION_URL, @@ -16,16 +16,27 @@ import { interface IndexTypeSelectorProps { accelerationFormData: CreateAccelerationForm; + isS3ConnectionWithLakeFormation: boolean; setAccelerationFormData: React.Dispatch>; initiateColumnLoad: (dataSource: string, database: string, dataTable: string) => void; } export const IndexTypeSelector = ({ accelerationFormData, + isS3ConnectionWithLakeFormation, setAccelerationFormData, initiateColumnLoad, }: IndexTypeSelectorProps) => { const [value, setValue] = useState('skipping'); + // This is used to track if user changed the value + // If so, we skip changing it based on 'isS3ConnectionWithLakeFormation' in the effect below + const valueSetAlready = useRef(false); + + useEffect(() => { + if (!valueSetAlready.current) { + setValue(isS3ConnectionWithLakeFormation ? 'materialized' : 'skipping'); + } + }, [isS3ConnectionWithLakeFormation]); useEffect(() => { initiateColumnLoad( @@ -43,23 +54,30 @@ export const IndexTypeSelector = ({ indexType === 'skipping' ? ACCELERATION_DEFUALT_SKIPPING_INDEX_NAME : '', }); setValue(indexType); + valueSetAlready.current = true; }; + const baseOptions = !isS3ConnectionWithLakeFormation + ? [ + { + value: 'skipping', + inputDisplay: 'Skipping index', + dropdownDisplay: ( + + Skipping index + +

+ Accelerate direct queries by storing table meta-data in OpenSearch. +

+
+
+ ), + }, + ] + : []; + const superSelectOptions = [ - { - value: 'skipping', - inputDisplay: 'Skipping index', - dropdownDisplay: ( - - Skipping index - -

- Accelerate direct queries by storing table meta-data in OpenSearch. -

-
-
- ), - }, + ...baseOptions, { value: 'covering', inputDisplay: 'Covering index',