Skip to content

Commit

Permalink
Fix create acceleration bugs (opensearch-project#1599) (opensearch-pr…
Browse files Browse the repository at this point in the history
…oject#1603)

* fix acceleration flyout minor bugs

* update snapshots

* update index name regex

---------

(cherry picked from commit 76d206c)

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
(cherry picked from commit b17afd3)
  • Loading branch information
opensearch-trigger-bot[bot] authored and A9 Swift Project User committed Apr 9, 2024
1 parent d5c677c commit 9f39f76
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 30 deletions.
4 changes: 2 additions & 2 deletions auto_sync_commit_metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"last_github_commit": "1f789157e21658a5da2291f2cd969bff78b7a275",
"last_gitfarm_commit": "b04c1f2631339082ca46d57b951249766a017715"
"last_github_commit": "b17afd337e002f3bf7a0fb89424840e838312d49",
"last_gitfarm_commit": "73dfd1fd06ba2cf4b104da0f5a1fe1bb31789ba7"
}
4 changes: 2 additions & 2 deletions common/constants/data_sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const ACCELERATION_TIME_INTERVAL = [
];

export const ACCELERATION_ADD_FIELDS_TEXT = '(add fields here)';
export const ACCELERATION_INDEX_NAME_REGEX = /^[a-z][a-z_]*$/;
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 TIMESTAMP_DATATYPE = 'timestamp';
Expand All @@ -60,7 +60,7 @@ export const ACCELERATION_INDEX_NAME_INFO = `All OpenSearch acceleration indices
- 'Materialized View' indices also enable users to define their index name, but they do not have a suffix.
- An example of a 'Materialized View' index name might look like: \`flint_mydatasource_mydb_mytable_myindexname\`.
##### Note:
- All user given index names must be in lowercase letters. Index name cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \, |, ?, #, >, or < are not allowed.
- All user given index names must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \, |, ?, #, >, or < are not allowed.
`;

export const SKIPPING_INDEX_ACCELERATION_METHODS = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ Array [
class="euiFormLabel euiFormRow__label"
for="random_html_id"
>
Index type
Acceleration type
</label>
<div
Expand Down Expand Up @@ -538,7 +538,7 @@ Array [
class="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Select the type of index you want to create. Each index type has benefits and costs.
Select the type of acceleration according to your use case.
</div>
</div>
</div>
Expand Down Expand Up @@ -1031,7 +1031,7 @@ Array [
class="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
</div>
</div>
</div>
Expand Down Expand Up @@ -1834,7 +1834,7 @@ Array [
className="euiFormLabel euiFormRow__label"
htmlFor="random_html_id"
>
Index type
Acceleration type
</label>
<div
Expand Down Expand Up @@ -1950,7 +1950,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Select the type of index you want to create. Each index type has benefits and costs.
Select the type of acceleration according to your use case.
</div>
</div>
</div>,
Expand Down Expand Up @@ -2528,7 +2528,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
</div>
</div>
</div>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('validateRefreshInterval', () => {

describe('validateIndexName', () => {
it('should return an array with an error message when the index name is invalid', () => {
expect(validateIndexName('_invalid')).toEqual(['Enter a valid index name']);
expect(validateIndexName('Iinvalid')).toEqual(['Enter a valid index name']);
expect(validateIndexName('-invalid')).toEqual(['Enter a valid index name']);
expect(validateIndexName('InVal1d')).toEqual(['Enter a valid index name']);
expect(validateIndexName('invalid_with spaces')).toEqual(['Enter a valid index name']);
Expand All @@ -147,9 +147,13 @@ describe('validateIndexName', () => {

it('should use the ACCELERATION_INDEX_NAME_REGEX pattern to validate the index name', () => {
expect(ACCELERATION_INDEX_NAME_REGEX.test('valid_name')).toBe(true);
expect(ACCELERATION_INDEX_NAME_REGEX.test('_valid_name')).toBe(true);
expect(ACCELERATION_INDEX_NAME_REGEX.test('23valid_name')).toBe(true);
expect(ACCELERATION_INDEX_NAME_REGEX.test('___1__')).toBe(true);
expect(ACCELERATION_INDEX_NAME_REGEX.test('23')).toBe(true);
expect(ACCELERATION_INDEX_NAME_REGEX.test('invalid name')).toBe(false);
expect(ACCELERATION_INDEX_NAME_REGEX.test('-invalid')).toBe(false);
expect(ACCELERATION_INDEX_NAME_REGEX.test('_invalid')).toBe(false);
expect(ACCELERATION_INDEX_NAME_REGEX.test('_invalid')).toBe(true);
expect(ACCELERATION_INDEX_NAME_REGEX.test('invalid.')).toBe(false);
expect(ACCELERATION_INDEX_NAME_REGEX.test('invalid<')).toBe(false);
expect(ACCELERATION_INDEX_NAME_REGEX.test('invalid*')).toBe(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export const CreateAcceleration = ({
<PreviewSQLDefinition
accelerationFormData={accelerationFormData}
setAccelerationFormData={setAccelerationFormData}
resetFlyout={resetFlyout}
/>
</EuiForm>
</EuiFlyoutBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const validateWatermarkDelay = (
};

export const validateIndexName = (value: string) => {
// Check if the value does not begin with underscores or hyphens and all characters are lower case
// Check if the value contains lower case letters, numbers and underscore
return !ACCELERATION_INDEX_NAME_REGEX.test(value) ? ['Enter a valid index name'] : [];
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
</div>
</div>
</div>,
Expand Down Expand Up @@ -200,7 +200,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
</div>
</div>
</div>,
Expand Down Expand Up @@ -298,7 +298,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
</div>
</div>
</div>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ exports[`Advanced Index settings acceleration components renders acceleration in
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \\, |, ?, #, &gt;, or &lt; are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.
</div>
</div>
</div>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Array [
className="euiFormLabel euiFormRow__label"
htmlFor="random_html_id"
>
Index type
Acceleration type
</label>
<div
Expand Down Expand Up @@ -140,7 +140,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Select the type of index you want to create. Each index type has benefits and costs.
Select the type of acceleration according to your use case.
</div>
</div>
</div>,
Expand Down Expand Up @@ -171,7 +171,7 @@ Array [
className="euiFormLabel euiFormRow__label"
htmlFor="random_html_id"
>
Index type
Acceleration type
</label>
<div
Expand Down Expand Up @@ -287,7 +287,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="random_html_id-help-0"
>
Select the type of index you want to create. Each index type has benefits and costs.
Select the type of acceleration according to your use case.
</div>
</div>
</div>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const DefineIndexOptions = ({
<>
<EuiFormRow
label="Index name"
helpText='Must be in lowercase letters. Cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \, |, ?, #, >, or < are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.'
helpText='Must be in lowercase letters, numbers and underscore. Spaces, commas, and characters -, :, ", *, +, /, \, |, ?, #, >, or < are not allowed. Prefix and suffix are added to the name of generated OpenSearch index.'
isInvalid={hasError(accelerationFormData.formErrors, 'indexNameError')}
error={accelerationFormData.formErrors.indexNameError}
labelAppend={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ export const IndexSettingOptions = ({
const [checkpoint, setCheckpoint] = useState('');

const onChangeRefreshType = (optionId: AccelerationRefreshType) => {
setAccelerationFormData({
...accelerationFormData,
refreshType: optionId,
});
setAccelerationFormData(
producer((accData) => {
accData.refreshType = optionId;
accData.formErrors.checkpointLocationError = [];
accData.formErrors.refreshIntervalError = [];
})
);
setRefreshTypeSelected(optionId);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ export const IndexTypeSelector = ({
</EuiText>
<EuiSpacer size="s" />
<EuiFormRow
label="Index type"
helpText="Select the type of index you want to create. Each index type has benefits and costs."
label="Acceleration type"
helpText="Select the type of acceleration according to your use case."
labelAppend={
<EuiText size="xs">
<EuiLink href={ACC_INDEX_TYPE_DOCUMENTATION_URL} target="_blank">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import { accelerationQueryBuilder } from '../visual_editors/query_builder';
interface PreviewSQLDefinitionProps {
accelerationFormData: CreateAccelerationForm;
setAccelerationFormData: React.Dispatch<React.SetStateAction<CreateAccelerationForm>>;
resetFlyout: () => void;
}

export const PreviewSQLDefinition = ({
accelerationFormData,
setAccelerationFormData,
resetFlyout,
}: PreviewSQLDefinitionProps) => {
const { setToast } = useToast();
const [isPreviewStale, setIsPreviewStale] = useState(false);
Expand Down Expand Up @@ -96,12 +98,13 @@ export const PreviewSQLDefinition = ({
queryToRun: accelerationQueryBuilder(accelerationFormData),
},
});
resetFlyout();
}
};

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

0 comments on commit 9f39f76

Please sign in to comment.