Skip to content

Commit

Permalink
adding minor updates to acceleration ui
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <[email protected]>
  • Loading branch information
ps48 committed Oct 4, 2023
1 parent 9a5a20f commit f5febda
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 35 deletions.
40 changes: 26 additions & 14 deletions public/components/SQLPage/acceleration_index_flyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,29 @@ export const AccelerationIndexFlyout = ({
</div>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<h3>Acceleration index Source</h3>
<EuiHorizontalRule />
<h2>Acceleration index Source</h2>
<EuiHorizontalRule margin="s" />
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiFlexItem>
<h3>Data Source</h3>
<EuiSpacer />
<p>{dataSource}</p>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFlexItem>
<h3>Database</h3>
<EuiSpacer />
<p>{database}</p>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFlexItem>
<h3>Table</h3>
<EuiSpacer />
<p>{dataTable}</p>
</EuiFlexItem>
</EuiFlexGroup>
<h3>Acceleration index destination</h3>
<EuiHorizontalRule />
<EuiHorizontalRule margin="s" />
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiFlexItem>
<h3>OpenSearch Index</h3>
<EuiSpacer />
<p>
Expand All @@ -103,23 +103,35 @@ export const AccelerationIndexFlyout = ({
</EuiFlexItem>
</EuiFlexGroup>
<h3>Acceleration index actions</h3>
<EuiHorizontalRule />
<EuiHorizontalRule margin="s" />
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiButton iconSide="right" fill iconType="lensApp" onClick={updateDescribeQuery}>
<EuiFlexItem>
<EuiButton
iconSide="right"
fill
iconType="lensApp"
onClick={updateDescribeQuery}
size="s"
>
Describe Index
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton iconSide="right" iconType="trash" onClick={updateDropQuery} color="danger">
<EuiFlexItem>
<EuiButton
iconSide="right"
iconType="trash"
onClick={updateDropQuery}
color="danger"
size="s"
>
Drop Index
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlyoutBody>
<EuiFlyoutFooter>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiFlexGroup>
<EuiFlexItem>
<EuiButtonEmpty iconType="cross" onClick={resetFlyout} flush="left">
Close
</EuiButtonEmpty>
Expand Down
14 changes: 9 additions & 5 deletions public/components/acceleration/selectors/index_type_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ export const IndexTypeSelector = ({
};
getJobId(query, http, (id: string) => {
pollQueryStatus(id, http, (data: any[]) => {
const dataTableFields: DataTableFieldsType[] = data.map((field, index) => ({
id: `${idPrefix}${index + 1}`,
fieldName: field.col_name,
dataType: field.data_type,
}));
console.log('data', data);
const dataTableFields: DataTableFieldsType[] = data
.filter((row) => !row[0].startsWith('#'))
.map((row, index) => ({
id: `${idPrefix}${index + 1}`,
fieldName: row[0],
dataType: row[1],
}));
console.log('dataTableFields', dataTableFields);
setAccelerationFormData({
...accelerationFormData,
dataTableFields: dataTableFields,
Expand Down
12 changes: 4 additions & 8 deletions public/components/acceleration/visual_editors/query_builder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ const buildSkippingIndexColumns = (skippingIndexQueryData: SkippingIndexRowType[
* Skipping Index create query example:
*
* CREATE SKIPPING INDEX
* ON datasource.database.table
* FOR COLUMNS (
* ON datasource.database.table (
* field1 VALUE_SET,
* field2 PARTITION,
* field3 MIN_MAX,
Expand All @@ -74,8 +73,7 @@ export const skippingIndexQueryBuilder = (accelerationformData: CreateAccelerati
const { dataSource, database, dataTable, skippingIndexQueryData } = accelerationformData;

const codeQuery = `CREATE SKIPPING INDEX
ON ${dataSource}.${database}.${dataTable}
FOR COLUMNS (
ON ${dataSource}.${database}.${dataTable} (
${buildSkippingIndexColumns(skippingIndexQueryData)}
) ${buildIndexOptions(accelerationformData)}`;

Expand All @@ -92,8 +90,7 @@ const buildCoveringIndexColumns = (coveringIndexQueryData: string[]) => {
* Covering Index create query example:
*
* CREATE INDEX index_name
* ON datasource.database.table
* FOR COLUMNS (
* ON datasource.database.table (
* field1,
* field2,
* field3,
Expand All @@ -114,8 +111,7 @@ export const coveringIndexQueryBuilder = (accelerationformData: CreateAccelerati
} = accelerationformData;

const codeQuery = `CREATE INDEX ${accelerationIndexName}
ON ${dataSource}.${database}.${dataTable}
FOR COLUMNS (
ON ${dataSource}.${database}.${dataTable} (
${buildCoveringIndexColumns(coveringIndexQueryData)}
) ${buildIndexOptions(accelerationformData)}`;

Expand Down
12 changes: 4 additions & 8 deletions test/mocks/accelerationMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ export const skippingIndexBuilderMock1: CreateAccelerationForm = {
};

export const skippingIndexBuilderMockResult1 = `CREATE SKIPPING INDEX
ON datasource.database.table
FOR COLUMNS (
ON datasource.database.table (
field1 PARTITION,
field2 VALUE_SET,
field3 MIN_MAX
Expand Down Expand Up @@ -234,8 +233,7 @@ export const skippingIndexBuilderMock2: CreateAccelerationForm = {
};

export const skippingIndexBuilderMockResult2 = `CREATE SKIPPING INDEX
ON datasource.database.table
FOR COLUMNS (
ON datasource.database.table (
field1 PARTITION
) WITH (
index_settings = '{"number_of_shards":5,"number_of_replicas":3}',
Expand All @@ -261,8 +259,7 @@ export const coveringIndexBuilderMock1: CreateAccelerationForm = {
};

export const coveringIndexBuilderMockResult1 = `CREATE INDEX index_name
ON datasource.database.table
FOR COLUMNS (
ON datasource.database.table (
field1,
field2,
field3
Expand All @@ -287,8 +284,7 @@ export const coveringIndexBuilderMock2: CreateAccelerationForm = {
};

export const coveringIndexBuilderMockResult2 = `CREATE INDEX index_name
ON datasource.database.table
FOR COLUMNS (
ON datasource.database.table (
field1
) WITH (
index_settings = '{"number_of_shards":5,"number_of_replicas":3}',
Expand Down

0 comments on commit f5febda

Please sign in to comment.