Skip to content

Commit

Permalink
acceleration bug fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>
  • Loading branch information
ps48 committed Mar 25, 2024
1 parent 4e1e0e5 commit c03c676
Show file tree
Hide file tree
Showing 13 changed files with 303 additions and 97 deletions.
5 changes: 4 additions & 1 deletion common/constants/data_sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand All @@ -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_<index name>_suffix\`. They share a common prefix structure, which is \`flint_<data source name>_<database name>_<table name>_\`. Additionally, they may have a suffix that varies based on the index type.
##### Skipping Index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,39 @@ Array [
>
Checkpoint location
</label>
<div
class="euiText euiText--extraSmall"
>
<a
class="euiLink euiLink--primary"
href="https://github.com/opensearch-project/opensearch-spark/blob/main/docs/index.md#create-index-options"
rel="noopener noreferrer"
target="_blank"
>
Learn more
<svg
aria-hidden="true"
aria-label="External link"
class="euiIcon euiIcon--small euiIcon-isLoading euiLink__externalIcon"
focusable="false"
height="16"
role="img"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M5.277 10.088c.02.014.04.03.057.047.582.55 1.134.812 1.666.812.586 0 1.84-.293 3.713-.88L9 6.212V2H7v4.212l-1.723 3.876Zm-.438.987L3.539 14h8.922l-1.32-2.969C9.096 11.677 7.733 12 7 12c-.74 0-1.463-.315-2.161-.925ZM6 2H5V1h6v1h-1v4l3.375 7.594A1 1 0 0 1 12.461 15H3.54a1 1 0 0 1-.914-1.406L6 6V2Z"
/>
</svg>
<span
class="euiScreenReaderOnly"
>
(opens in a new tab or window)
</span>
</a>
</div>
</div>
<div
class="euiFormRow__fieldWrapper"
Expand Down Expand Up @@ -814,7 +847,7 @@ Array [
<span
class="euiTableCellContent__text"
>
Please add fields
You have no definitions defined.
</span>
</div>
</td>
Expand Down Expand Up @@ -2081,6 +2114,40 @@ Array [
>
Checkpoint location
</label>
<div
className="euiText euiText--extraSmall"
>
<a
className="euiLink euiLink--primary"
href="https://github.com/opensearch-project/opensearch-spark/blob/main/docs/index.md#create-index-options"
rel="noopener noreferrer"
target="_blank"
>
Learn more
<svg
aria-hidden={true}
aria-label="External link"
className="euiIcon euiIcon--small euiIcon-isLoading euiLink__externalIcon"
focusable="false"
height={16}
role="img"
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M5.277 10.088c.02.014.04.03.057.047.582.55 1.134.812 1.666.812.586 0 1.84-.293 3.713-.88L9 6.212V2H7v4.212l-1.723 3.876Zm-.438.987L3.539 14h8.922l-1.32-2.969C9.096 11.677 7.733 12 7 12c-.74 0-1.463-.315-2.161-.925ZM6 2H5V1h6v1h-1v4l3.375 7.594A1 1 0 0 1 12.461 15H3.54a1 1 0 0 1-.914-1.406L6 6V2Z"
/>
</svg>
<span
className="euiScreenReaderOnly"
>
(opens in a new tab or window)
</span>
</a>
</div>
</div>
<div
className="euiFormRow__fieldWrapper"
Expand Down Expand Up @@ -2271,7 +2338,7 @@ Array [
<span
className="euiTableCellContent__text"
>
Please add fields
You have no definitions defined.
</span>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -51,6 +52,7 @@ export const CreateAcceleration = ({
databaseName,
tableName,
}: CreateAccelerationProps) => {
const { setToast } = useToast();
const http = coreRefs!.http;
const [accelerationFormData, setAccelerationFormData] = useState<CreateAccelerationForm>({
dataSource: selectedDatasource,
Expand Down Expand Up @@ -135,13 +137,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);
}
}
};
Expand All @@ -159,11 +165,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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ export const CreateAccelerationButton = ({
status === DirectQueryLoadingStatus.CANCELED
) {
setIsLoading(false);
setToast('Create acceleration query failed', 'success');
}
}, [directqueryLoadStatus]);

return (
<EuiButton onClick={createAcceleration} fill isLoading={isLoading}>
Create acceleration
{isLoading ? 'Creating acceleration' : 'Create acceleration'}
</EuiButton>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,40 @@ Array [
>
Checkpoint location
</label>
<div
className="euiText euiText--extraSmall"
>
<a
className="euiLink euiLink--primary"
href="https://github.com/opensearch-project/opensearch-spark/blob/main/docs/index.md#create-index-options"
rel="noopener noreferrer"
target="_blank"
>
Learn more
<svg
aria-hidden={true}
aria-label="External link"
className="euiIcon euiIcon--small euiIcon-isLoading euiLink__externalIcon"
focusable="false"
height={16}
role="img"
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M5.277 10.088c.02.014.04.03.057.047.582.55 1.134.812 1.666.812.586 0 1.84-.293 3.713-.88L9 6.212V2H7v4.212l-1.723 3.876Zm-.438.987L3.539 14h8.922l-1.32-2.969C9.096 11.677 7.733 12 7 12c-.74 0-1.463-.315-2.161-.925ZM6 2H5V1h6v1h-1v4l3.375 7.594A1 1 0 0 1 12.461 15H3.54a1 1 0 0 1-.914-1.406L6 6V2Z"
/>
</svg>
<span
className="euiScreenReaderOnly"
>
(opens in a new tab or window)
</span>
</a>
</div>
</div>
<div
className="euiFormRow__fieldWrapper"
Expand Down Expand Up @@ -284,6 +318,39 @@ Array [
>
Checkpoint location
</label>
<div
className="euiText euiText--extraSmall"
>
<a
className="euiLink euiLink--primary"
href="https://github.com/opensearch-project/opensearch-spark/blob/main/docs/index.md#create-index-options"
rel="noopener noreferrer"
target="_blank"
>
Learn more
<svg
aria-label="External link"
className="euiIcon euiIcon--small euiLink__externalIcon"
focusable="false"
height={16}
role="img"
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M13 8.5a.5.5 0 1 1 1 0V12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h3.5a.5.5 0 0 1 0 1H4a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V8.5Zm-5.12.339a.5.5 0 1 1-.706-.707L13.305 2H10.5a.5.5 0 1 1 0-1H14a1 1 0 0 1 1 1v3.5a.5.5 0 1 1-1 0V2.72L7.88 8.838Z"
/>
</svg>
<span
className="euiScreenReaderOnly"
>
(opens in a new tab or window)
</span>
</a>
</div>
</div>
<div
className="euiFormRow__fieldWrapper"
Expand Down Expand Up @@ -444,6 +511,39 @@ Array [
>
Checkpoint location
</label>
<div
className="euiText euiText--extraSmall"
>
<a
className="euiLink euiLink--primary"
href="https://github.com/opensearch-project/opensearch-spark/blob/main/docs/index.md#create-index-options"
rel="noopener noreferrer"
target="_blank"
>
Learn more
<svg
aria-label="External link"
className="euiIcon euiIcon--small euiLink__externalIcon"
focusable="false"
height={16}
role="img"
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M13 8.5a.5.5 0 1 1 1 0V12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h3.5a.5.5 0 0 1 0 1H4a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V8.5Zm-5.12.339a.5.5 0 1 1-.706-.707L13.305 2H10.5a.5.5 0 1 1 0-1H14a1 1 0 0 1 1 1v3.5a.5.5 0 1 1-1 0V2.72L7.88 8.838Z"
/>
</svg>
<span
className="euiScreenReaderOnly"
>
(opens in a new tab or window)
</span>
</a>
</div>
</div>
<div
className="euiFormRow__fieldWrapper"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import {
EuiFieldNumber,
EuiFieldText,
EuiFormRow,
EuiLink,
EuiSelect,
EuiSpacer,
EuiSuperSelect,
EuiText,
} from '@elastic/eui';
import producer from 'immer';
import React, { ChangeEvent, Fragment, useState } from 'react';
import { ACCELERATION_TIME_INTERVAL } from '../../../../../../../../common/constants/data_sources';
import {
ACC_CHECKPOINT_DOCUMENTATION_URL,
ACCELERATION_TIME_INTERVAL,
} from '../../../../../../../../common/constants/data_sources';
import {
AccelerationRefreshType,
CreateAccelerationForm,
Expand Down Expand Up @@ -221,6 +225,13 @@ export const IndexSettingOptions = ({
helpText="The HDFS compatible file system location path for incremental refresh job checkpoint."
isInvalid={hasError(accelerationFormData.formErrors, 'checkpointLocationError')}
error={accelerationFormData.formErrors.checkpointLocationError}
labelAppend={
<EuiText size="xs">
<EuiLink href={ACC_CHECKPOINT_DOCUMENTATION_URL} target="_blank">
Learn more
</EuiLink>
</EuiText>
}
>
<EuiFieldText
placeholder="s3://checkpoint/location"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const PreviewSQLDefinition = ({

const queryWorkbenchButton = sqlWorkbenchPLuginExists ? (
<EuiButton iconSide="right" onClick={openInWorkbench}>
Continue in Query Workbench
Edit in Query Workbench
</EuiButton>
) : (
<></>
Expand Down
Loading

0 comments on commit c03c676

Please sign in to comment.