Skip to content

Commit

Permalink
Lake formation support updates (#1871)
Browse files Browse the repository at this point in the history
* modified get tables query for iceberg tables

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* updated integration setup for security lake

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* filter connection type option based on integration workflows

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* updated code to use connector type for Security Lake

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* fixed logic to select default index type in create acceleration

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* updated tests

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

---------

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>
  • Loading branch information
amsiglan committed Jun 7, 2024
1 parent e5af7eb commit 19d68b2
Show file tree
Hide file tree
Showing 31 changed files with 531 additions and 540 deletions.
1 change: 1 addition & 0 deletions common/constants/data_connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const QUERY_ALL = 'query-all';
export const DatasourceTypeToDisplayName: { [key in DatasourceType]: string } = {
PROMETHEUS: 'Prometheus',
S3GLUE: 'Amazon S3',
SECURITYLAKE: 'Amazon Security Lake',
};

export const PrometheusURL = 'Prometheus';
Expand Down
7 changes: 4 additions & 3 deletions common/types/data_connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ export interface AssociatedObject {

export type Role = EuiComboBoxOptionOption;

export type DatasourceType = 'S3GLUE' | 'PROMETHEUS';
export type DatasourceType = 'S3GLUE' | 'PROMETHEUS' | 'SECURITYLAKE';

export interface S3GlueProperties {
'glue.indexstore.opensearch.uri': string;
'glue.indexstore.opensearch.region': string;
'glue.lakeformation.enabled'?: boolean;
}

export interface PrometheusProperties {
Expand Down Expand Up @@ -252,10 +251,12 @@ export interface StartLoadingParams {
dataSourceMDSId?: string;
databaseName?: string;
tableName?: string;
dataSourceType?: DatasourceType;
}

export interface RenderAccelerationFlyoutParams {
dataSource: string;
dataSourceType: DatasourceType;
dataSourceMDSId?: string;
databaseName?: string;
tableName?: string;
Expand All @@ -265,9 +266,9 @@ export interface RenderAccelerationFlyoutParams {
export interface RenderAssociatedObjectsDetailsFlyoutParams {
tableDetail: AssociatedObject;
dataSourceName: string;
dataSourceType: DatasourceType;
handleRefresh?: () => void;
dataSourceMDSId?: string;
isS3ConnectionWithLakeFormation?: boolean;
}

export interface RenderAccelerationDetailsFlyoutParams {
Expand Down
6 changes: 6 additions & 0 deletions common/types/integrations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export type IntegrationConnectionType = 's3' | 'index' | 'securityLake';
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object
>
<CreateAccelerationFlyoutButton
dataSourceName="mock_data_source"
dataSourceType="S3GLUE"
handleRefresh={[Function]}
renderCreateAccelerationFlyout={[MockFunction]}
>
Expand Down Expand Up @@ -738,9 +739,9 @@ exports[`AssociatedObjectsTab Component renders correctly with associated object
},
]
}
dataSourceType="S3GLUE"
datasourceName="mock_data_source"
handleRefresh={[Function]}
isS3ConnectionWithLakeFormation={false}
>
<EuiInMemoryTable
columns={
Expand Down Expand Up @@ -5197,6 +5198,7 @@ exports[`AssociatedObjectsTab Component renders tab with no databases or objects
>
<CreateAccelerationFlyoutButton
dataSourceName="mock_data_source"
dataSourceType="S3GLUE"
handleRefresh={[Function]}
renderCreateAccelerationFlyout={[MockFunction]}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ exports[`Installed Integrations Table test Renders the installed integrations ta
Array [
Object {
"assets": 3,
"id": "d5b55c60-e08c-11ee-9c80-ff3b93498fea",
"locator": Object {
"id": "d5b55c60-e08c-11ee-9c80-ff3b93498fea",
"name": "aws_waf-sample",
Expand Down Expand Up @@ -444,6 +445,7 @@ exports[`Installed Integrations Table test Renders the installed integrations ta
Array [
Object {
"assets": 3,
"id": "d5b55c60-e08c-11ee-9c80-ff3b93498fea",
"locator": Object {
"id": "d5b55c60-e08c-11ee-9c80-ff3b93498fea",
"name": "aws_waf-sample",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ describe('AccelerationTable Component', () => {

it('renders without crashing', () => {
const wrapper = mount(
<AccelerationTable dataSourceName="testDataSource" cacheLoadingHooks={cacheLoadingHooks} />
<AccelerationTable
dataSourceName="testDataSource"
cacheLoadingHooks={cacheLoadingHooks}
dataSourceType="S3GLUE"
/>
);
expect(wrapper).toBeDefined();
});
Expand All @@ -111,7 +115,11 @@ describe('AccelerationTable Component', () => {
let wrapper: ReactWrapper;
await act(async () => {
wrapper = mount(
<AccelerationTable dataSourceName="testDataSource" cacheLoadingHooks={cacheLoadingHooks} />
<AccelerationTable
dataSourceName="testDataSource"
cacheLoadingHooks={cacheLoadingHooks}
dataSourceType="S3GLUE"
/>
);
});

Expand All @@ -132,7 +140,11 @@ describe('AccelerationTable Component', () => {
let wrapper: ReactWrapper;
await act(async () => {
wrapper = mount(
<AccelerationTable dataSourceName="testDataSource" cacheLoadingHooks={cacheLoadingHooks} />
<AccelerationTable
dataSourceName="testDataSource"
cacheLoadingHooks={cacheLoadingHooks}
dataSourceType="S3GLUE"
/>
);
});
wrapper!.update();
Expand All @@ -152,7 +164,11 @@ describe('AccelerationTable Component', () => {
let wrapper: ReactWrapper;
await act(async () => {
wrapper = mount(
<AccelerationTable dataSourceName="testDataSource" cacheLoadingHooks={cacheLoadingHooks} />
<AccelerationTable
dataSourceName="testDataSource"
cacheLoadingHooks={cacheLoadingHooks}
dataSourceType="S3GLUE"
/>
);
await new Promise((resolve) => setTimeout(resolve, 0));
wrapper!.update();
Expand All @@ -172,7 +188,11 @@ describe('AccelerationTable Component', () => {
let wrapper: ReactWrapper;
await act(async () => {
wrapper = mount(
<AccelerationTable dataSourceName="testDataSource" cacheLoadingHooks={cacheLoadingHooks} />
<AccelerationTable
dataSourceName="testDataSource"
cacheLoadingHooks={cacheLoadingHooks}
dataSourceType="S3GLUE"
/>
);
});
wrapper!.update();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import React, { useCallback, useEffect, useState } from 'react';
import {
CachedAcceleration,
CachedDataSourceStatus,
DatasourceType,
} from '../../../../../../common/types/data_connections';
import { DirectQueryLoadingStatus } from '../../../../../../common/types/explorer';
import { CatalogCacheManager } from '../../../../../framework/catalog_cache/cache_manager';
Expand All @@ -45,7 +46,7 @@ import {
interface AccelerationTableProps {
dataSourceName: string;
cacheLoadingHooks: any;
isS3ConnectionWithLakeFormation: boolean;
dataSourceType: DatasourceType;
}

interface ModalState {
Expand All @@ -56,7 +57,7 @@ interface ModalState {
export const AccelerationTable = ({
dataSourceName,
cacheLoadingHooks,
isS3ConnectionWithLakeFormation,
dataSourceType,
}: AccelerationTableProps) => {
const [accelerations, setAccelerations] = useState<CachedAcceleration[]>([]);
const [updatedTime, setUpdatedTime] = useState<string>();
Expand Down Expand Up @@ -171,6 +172,7 @@ export const AccelerationTable = ({
<EuiFlexItem grow={false}>
<CreateAccelerationFlyoutButton
dataSourceName={dataSourceName}
dataSourceType={dataSourceType}
renderCreateAccelerationFlyout={renderCreateAccelerationFlyout}
handleRefresh={handleRefresh}
/>
Expand Down Expand Up @@ -327,11 +329,12 @@ export const AccelerationTable = ({
},
};

const accelerationTableColumns = !isS3ConnectionWithLakeFormation
? Object.values(accelerationTableColumnsCollection)
: Object.entries(accelerationTableColumnsCollection)
.filter(([key]) => key !== 'database' && key !== 'table')
.map(([_key, val]) => val);
const accelerationTableColumns =
dataSourceType.toUpperCase() === 'SECURITYLAKE'
? Object.entries(accelerationTableColumnsCollection)
.filter(([key]) => key !== 'database' && key !== 'table')
.map(([_key, val]) => val)
: Object.values(accelerationTableColumnsCollection);

const pagination = {
initialPageSize: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ describe('Create acceleration flyout components', () => {
coreStartMock.http.get = jest.fn().mockResolvedValue(mockDatasourcesQuery);

const wrapper = mount(
<CreateAcceleration selectedDatasource={selectedDatasource} resetFlyout={resetFlyout} />
<CreateAcceleration
selectedDatasource={selectedDatasource}
resetFlyout={resetFlyout}
selectedDatasourceType="S3GLUE"
/>
);
wrapper.update();
await waitFor(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import {
CachedTable,
CreateAccelerationForm,
DatasourceType,
} from '../../../../../../../../common/types/data_connections';
import { DirectQueryLoadingStatus } from '../../../../../../../../common/types/explorer';
import { useLoadTableColumnsToCache } from '../../../../../../../framework/catalog_cache/cache_loader';
Expand All @@ -39,11 +40,10 @@ 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';
import { checkIsConnectionWithLakeFormation } from '../../../../../utils/helpers';

export interface CreateAccelerationProps {
selectedDatasource: string;
selectedDatasourceType: DatasourceType;
resetFlyout: () => void;
databaseName?: string;
tableName?: string;
Expand All @@ -53,6 +53,7 @@ export interface CreateAccelerationProps {

export const CreateAcceleration = ({
selectedDatasource,
selectedDatasourceType,
resetFlyout,
databaseName,
tableName,
Expand All @@ -61,13 +62,12 @@ export const CreateAcceleration = ({
}: CreateAccelerationProps) => {
const { setToast } = useToast();
const http = coreRefs!.http;
const [isS3ConnectionWithLakeFormation, setIsS3ConnectionWithLakeFormation] = useState(false);
const [accelerationFormData, setAccelerationFormData] = useState<CreateAccelerationForm>({
dataSource: selectedDatasource,
database: databaseName ?? '',
dataTable: tableName ?? '',
dataTableFields: [],
accelerationIndexType: 'skipping',
accelerationIndexType: selectedDatasourceType === 'SECURITYLAKE' ? 'materialized' : 'skipping',
skippingIndexQueryData: [],
coveringIndexQueryData: [],
materializedViewQueryData: {
Expand Down Expand Up @@ -170,16 +170,6 @@ export const CreateAcceleration = ({
}
};

const updateDataSourceConnectionInfo = () => {
coreRefs.http!.get(`${DATACONNECTIONS_BASE}/${selectedDatasource}`).then((data: any) => {
setIsS3ConnectionWithLakeFormation(checkIsConnectionWithLakeFormation(data));
});
};

useEffect(() => {
updateDataSourceConnectionInfo();
}, [selectedDatasource]);

useEffect(() => {
if (databaseName !== undefined && tableName !== undefined) {
initiateColumnLoad(
Expand Down Expand Up @@ -245,14 +235,15 @@ export const CreateAcceleration = ({
setDataSourceFormData: setAccelerationFormData,
}}
selectedDatasource={selectedDatasource}
selectedDataSourceType={selectedDatasourceType}
dataSourcesPreselected={dataSourcesPreselected}
tableFieldsLoading={tableFieldsLoading}
dataSourceMDSId={dataSourceMDSId}
/>
<EuiSpacer size="xxl" />
<IndexTypeSelector
accelerationFormData={accelerationFormData}
isS3ConnectionWithLakeFormation={isS3ConnectionWithLakeFormation}
dataSourceType={selectedDatasourceType}
setAccelerationFormData={setAccelerationFormData}
initiateColumnLoad={initiateColumnLoad}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ describe('Index type selector components', () => {
const wrapper = mount(
<IndexTypeSelector
accelerationFormData={accelerationFormData}
dataSourceType="S3GLUE"
setAccelerationFormData={setAccelerationFormData}
initiateColumnLoad={jest.fn()}
loading={false}
/>
);
wrapper.update();
Expand All @@ -46,9 +46,9 @@ describe('Index type selector components', () => {
const wrapper = mount(
<IndexTypeSelector
accelerationFormData={accelerationFormData}
dataSourceType="S3GLUE"
setAccelerationFormData={setAccelerationFormData}
initiateColumnLoad={jest.fn()}
loading={true}
/>
);
wrapper.update();
Expand Down
Loading

0 comments on commit 19d68b2

Please sign in to comment.