Skip to content

Commit

Permalink
Revert "Session update, minor fixes for acceleration flyout (opensear…
Browse files Browse the repository at this point in the history
  • Loading branch information
mengweieric committed Nov 8, 2023
1 parent bcdae52 commit 9dc81b9
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 65 deletions.
3 changes: 1 addition & 2 deletions common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const SKIPPING_INDEX_ACCELERATION_METHODS = [

export const ACCELERATION_ADD_FIELDS_TEXT = '(add fields here)';
export const ACCELERATION_INDEX_NAME_REGEX = /^[a-z][a-z_]*$/;
export const ACCELERATION_S3_URL_REGEX = /^(s3|s3a):\/\/[a-zA-Z0-9.\-]+/;
export const ACCELERATION_S3_URL_REGEX = /^(s3|s3a):\/\/[a-zA-Z0-9.\-]+\/.*/;
export const ACCELERATION_DEFUALT_SKIPPING_INDEX_NAME = 'skipping';

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.
Expand All @@ -89,7 +89,6 @@ export const ACCELERATION_INDEX_NAME_INFO = `All OpenSearch acceleration indices
- All user given index names must be in lowercase letters. Index name cannot begin with underscores. Spaces, commas, and characters -, :, ", *, +, /, \, |, ?, #, >, or < are not allowed.
`;

export const OPENSEARCH_SQL_INIT_QUERY = `SHOW tables LIKE '%';`;
export const TIMESTAMP_DATATYPE = 'timestamp';
export const FETCH_OPENSEARCH_INDICES_PATH = '/api/sql_console/sqlquery';
export const POLL_INTERVAL_MS = 2000;
Expand Down
5 changes: 2 additions & 3 deletions common/utils/async_query_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import {
} from '../constants';

export const setAsyncSessionId = (value: string | null) => {
if (value !== null) {
sessionStorage.setItem(ASYNC_QUERY_SESSION_ID, value);
}
if (value === null) sessionStorage.removeItem(ASYNC_QUERY_SESSION_ID);
else sessionStorage.setItem(ASYNC_QUERY_SESSION_ID, value);
};

export const getAsyncSessionId = () => {
Expand Down
10 changes: 3 additions & 7 deletions public/components/Main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { ChromeBreadcrumb, CoreStart } from '../../../../../src/core/public';
import {
ASYNC_QUERY_ENDPOINT,
ASYNC_QUERY_JOB_ENDPOINT,
OPENSEARCH_SQL_INIT_QUERY,
POLL_INTERVAL_MS,
} from '../../../common/constants';
import { AsyncQueryLoadingStatus } from '../../../common/types';
Expand Down Expand Up @@ -240,7 +239,7 @@ export class Main extends React.Component<MainProps, MainState> {
this.onChange = this.onChange.bind(this);
this.state = {
language: 'SQL',
sqlQueriesString: OPENSEARCH_SQL_INIT_QUERY,
sqlQueriesString: "SHOW tables LIKE '%';",
pplQueriesString: '',
queries: [],
queryTranslations: [],
Expand Down Expand Up @@ -817,11 +816,8 @@ export class Main extends React.Component<MainProps, MainState> {
}

handleDataSelect = (selectedItems: EuiComboBoxOptionOption[]) => {
this.updateSQLQueries('');
this.updatePPLQueries('');
this.onClear();
if (selectedItems[0].label === 'OpenSearch' && this.state.language === 'SQL') {
this.updateSQLQueries(OPENSEARCH_SQL_INIT_QUERY);
if (selectedItems[0].label !== 'OpenSearch' && this.state.language === 'SQL') {
this.updateSQLQueries('');
}
this.setState({
selectedDatasource: selectedItems,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,15 +574,15 @@ Array [
min="1"
placeholder="Number of primary shards"
type="number"
value="5"
value="1"
/>
</div>
</div>
<div
class="euiFormHelpText euiFormRow__text"
id="some_html_id-help-0"
>
Specify the number of primary shards for the index. The number of primary shards cannot be changed after the index is created.
Specify the number of primary shards for the index. Default is 1. The number of primary shards cannot be changed after the index is created.
</div>
</div>
</div>
Expand Down Expand Up @@ -627,7 +627,7 @@ Array [
class="euiFormHelpText euiFormRow__text"
id="some_html_id-help-0"
>
Specify the number of replicas each primary shard should have.
Specify the number of replicas each primary shard should have. Default is 1.
</div>
</div>
</div>
Expand Down Expand Up @@ -1819,15 +1819,15 @@ Array [
onFocus={[Function]}
placeholder="Number of primary shards"
type="number"
value={5}
value={1}
/>
</div>
</div>
<div
className="euiFormHelpText euiFormRow__text"
id="some_html_id-help-0"
>
Specify the number of primary shards for the index. The number of primary shards cannot be changed after the index is created.
Specify the number of primary shards for the index. Default is 1. The number of primary shards cannot be changed after the index is created.
</div>
</div>
</div>,
Expand Down Expand Up @@ -1875,7 +1875,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="some_html_id-help-0"
>
Specify the number of replicas each primary shard should have.
Specify the number of replicas each primary shard should have. Default is 1.
</div>
</div>
</div>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ describe('validateCheckpointLocation', () => {
expect(validCheckpoint).toEqual([]);
});

it('should return an empty array when the checkpoint location is a valid S3A URL with just bucket in checkpoint', () => {
const validCheckpoint = validateCheckpointLocation('auto', 's3a://valid-s3-bucket');
expect(validCheckpoint).toEqual([]);
});

it('should return an empty array when using manual refresh with no checkpoint location', () => {
const validMaterializedCheckpoint = validateCheckpointLocation('manual', '');
expect(validMaterializedCheckpoint).toEqual([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const CreateAcceleration = ({
},
},
accelerationIndexName: ACCELERATION_DEFUALT_SKIPPING_INDEX_NAME,
primaryShardsCount: 5,
primaryShardsCount: 1,
replicaShardsCount: 1,
refreshType: 'auto',
checkpointLocation: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ Array [
className="euiFormLabel euiFormControlLayout__prepend"
htmlFor="some_html_id"
>
flint_{Datasource Name}_{Database Name}_
flint_{Datasource Name}_{Database Name}_{Table Name}_
</label>
<span
className="euiToolTipAnchor"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,15 @@ Array [
onFocus={[Function]}
placeholder="Number of primary shards"
type="number"
value={5}
value={1}
/>
</div>
</div>
<div
className="euiFormHelpText euiFormRow__text"
id="some_html_id-help-0"
>
Specify the number of primary shards for the index. The number of primary shards cannot be changed after the index is created.
Specify the number of primary shards for the index. Default is 1. The number of primary shards cannot be changed after the index is created.
</div>
</div>
</div>,
Expand Down Expand Up @@ -252,7 +252,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="some_html_id-help-0"
>
Specify the number of replicas each primary shard should have.
Specify the number of replicas each primary shard should have. Default is 1.
</div>
</div>
</div>,
Expand Down Expand Up @@ -604,15 +604,15 @@ Array [
onFocus={[Function]}
placeholder="Number of primary shards"
type="number"
value={5}
value={1}
/>
</div>
</div>
<div
className="euiFormHelpText euiFormRow__text"
id="some_html_id-help-0"
>
Specify the number of primary shards for the index. The number of primary shards cannot be changed after the index is created.
Specify the number of primary shards for the index. Default is 1. The number of primary shards cannot be changed after the index is created.
</div>
</div>
</div>,
Expand Down Expand Up @@ -660,7 +660,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="some_html_id-help-0"
>
Specify the number of replicas each primary shard should have.
Specify the number of replicas each primary shard should have. Default is 1.
</div>
</div>
</div>,
Expand Down Expand Up @@ -1012,15 +1012,15 @@ Array [
onFocus={[Function]}
placeholder="Number of primary shards"
type="number"
value={5}
value={1}
/>
</div>
</div>
<div
className="euiFormHelpText euiFormRow__text"
id="some_html_id-help-0"
>
Specify the number of primary shards for the index. The number of primary shards cannot be changed after the index is created.
Specify the number of primary shards for the index. Default is 1. The number of primary shards cannot be changed after the index is created.
</div>
</div>
</div>,
Expand Down Expand Up @@ -1068,7 +1068,7 @@ Array [
className="euiFormHelpText euiFormRow__text"
id="some_html_id-help-0"
>
Specify the number of replicas each primary shard should have.
Specify the number of replicas each primary shard should have. Default is 1.
</div>
</div>
</div>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ export const DefineIndexOptions = ({
accelerationFormData.database !== '' ? accelerationFormData.database : '{Database Name}';
const dataTable =
accelerationFormData.dataTable !== '' ? accelerationFormData.dataTable : '{Table Name}';
const prependValue =
accelerationFormData.accelerationIndexType === 'materialized'
? `flint_${dataSource}_${database}_`
: `flint_${dataSource}_${database}_${dataTable}_`;
const prependValue = `flint_${dataSource}_${database}_${dataTable}_`;
return [
prependValue,
<EuiIconTip type="iInCircle" color="subdued" content={prependValue} position="top" />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const IndexSettingOptions = ({
},
];

const [primaryShards, setPrimaryShards] = useState(5);
const [primaryShards, setPrimaryShards] = useState(1);
const [replicaCount, setReplicaCount] = useState(1);
const [refreshTypeSelected, setRefreshTypeSelected] = useState(autoRefreshId);
const [refreshWindow, setRefreshWindow] = useState(1);
Expand Down Expand Up @@ -156,7 +156,7 @@ export const IndexSettingOptions = ({
/>
<EuiFormRow
label="Number of primary shards"
helpText="Specify the number of primary shards for the index. The number of primary shards cannot be changed after the index is created."
helpText="Specify the number of primary shards for the index. Default is 1. The number of primary shards cannot be changed after the index is created."
isInvalid={hasError(accelerationFormData.formErrors, 'primaryShardsError')}
error={accelerationFormData.formErrors.primaryShardsError}
>
Expand All @@ -181,7 +181,7 @@ export const IndexSettingOptions = ({
</EuiFormRow>
<EuiFormRow
label="Number of replicas"
helpText="Specify the number of replicas each primary shard should have."
helpText="Specify the number of replicas each primary shard should have. Default is 1."
isInvalid={hasError(accelerationFormData.formErrors, 'replicaShardsError')}
error={accelerationFormData.formErrors.replicaShardsError}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
ACCELERATION_INDEX_TYPES,
ACC_INDEX_TYPE_DOCUMENTATION_URL,
} from '../../../../common/constants';
import { useToast } from '../../../../common/toast';
import {
AccelerationIndexType,
CreateAccelerationForm,
Expand All @@ -37,7 +36,6 @@ export const IndexTypeSelector = ({
accelerationFormData,
setAccelerationFormData,
}: IndexTypeSelectorProps) => {
const { setToast } = useToast();
const [selectedIndexType, setSelectedIndexType] = useState<EuiComboBoxOptionOption<string>[]>([
ACCELERATION_INDEX_TYPES[0],
]);
Expand All @@ -52,11 +50,7 @@ export const IndexTypeSelector = ({
query: `DESC ${accelerationFormData.dataSource}.${accelerationFormData.database}.${accelerationFormData.dataTable}`,
datasource: accelerationFormData.dataSource,
};
const errorMessage = 'ERROR: failed to load table columns';
getJobId(query, http, (id: string) => {
if (id === undefined) {
setToast(errorMessage, 'danger');
}
pollQueryStatus(id, http, (data: { status: string; results: any[] }) => {
if (data.status === 'SUCCESS') {
const dataTableFields: DataTableFieldsType[] = data.results
Expand All @@ -74,7 +68,6 @@ export const IndexTypeSelector = ({
}
if (data.status === 'FAILED') {
setLoading(false);
setToast(errorMessage, 'danger');
}
});
});
Expand Down
13 changes: 0 additions & 13 deletions public/components/acceleration/selectors/source_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow, EuiSpacer, EuiText }
import producer from 'immer';
import React, { useEffect, useState } from 'react';
import { CoreStart } from '../../../../../../src/core/public';
import { useToast } from '../../../../common/toast';
import { CreateAccelerationForm } from '../../../../common/types';
import { getJobId, pollQueryStatus } from '../../../../common/utils/async_query_helpers';
import { hasError, validateDataSource } from '../create/utils';
Expand All @@ -25,7 +24,6 @@ export const AccelerationDataSourceSelector = ({
setAccelerationFormData,
selectedDatasource,
}: AccelerationDataSourceSelectorProps) => {
const { setToast } = useToast();
const [dataConnections, setDataConnections] = useState<EuiComboBoxOptionOption<string>[]>([]);
const [selectedDataConnection, setSelectedDataConnection] = useState<
EuiComboBoxOptionOption<string>[]
Expand Down Expand Up @@ -54,7 +52,6 @@ export const AccelerationDataSourceSelector = ({
})
.catch((err) => {
console.error(err);
setToast(`ERROR: failed to load datasources`, 'danger');
});
setLoadingComboBoxes({ ...loadingComboBoxes, dataSource: false });
};
Expand All @@ -66,11 +63,7 @@ export const AccelerationDataSourceSelector = ({
query: `SHOW SCHEMAS IN ${accelerationFormData.dataSource}`,
datasource: accelerationFormData.dataSource,
};
const errorMessage = `ERROR: failed to load databases`;
getJobId(query, http, (id: string) => {
if (id === undefined) {
setToast(errorMessage, 'danger');
}
pollQueryStatus(id, http, (data: { status: string; results: any[] }) => {
if (data.status === 'SUCCESS') {
let databaseOptions: EuiComboBoxOptionOption<string>[] = [];
Expand All @@ -81,7 +74,6 @@ export const AccelerationDataSourceSelector = ({
}
if (data.status === 'FAILED') {
setLoadingComboBoxes({ ...loadingComboBoxes, database: false });
setToast(errorMessage, 'danger');
}
});
});
Expand All @@ -94,11 +86,7 @@ export const AccelerationDataSourceSelector = ({
query: `SHOW TABLES IN ${accelerationFormData.dataSource}.${accelerationFormData.database}`,
datasource: accelerationFormData.dataSource,
};
const errorMessage = `ERROR: failed to load tables`;
getJobId(query, http, (id: string) => {
if (id === undefined) {
setToast(errorMessage, 'danger');
}
pollQueryStatus(id, http, (data: { status: string; results: any[] }) => {
if (data.status === 'SUCCESS') {
let dataTableOptions: EuiComboBoxOptionOption<string>[] = [];
Expand All @@ -109,7 +97,6 @@ export const AccelerationDataSourceSelector = ({
}
if (data.status === 'FAILED') {
setLoadingComboBoxes({ ...loadingComboBoxes, dataTable: false });
setToast(errorMessage, 'danger');
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
CreateAccelerationForm,
MaterializedViewColumn,
} from '../../../../../common/types';
import { validateMaterializedViewData } from '../../create/utils';

interface AddColumnPopOverProps {
isColumnPopOverOpen: boolean;
Expand Down Expand Up @@ -81,6 +82,10 @@ export const AddColumnPopOver = ({
setAccelerationFormData(
producer((accData) => {
accData.materializedViewQueryData.columnsValues = newColumnExpresionValue;
accData.formErrors.materializedViewError = validateMaterializedViewData(
accData.accelerationIndexType,
accData.materializedViewQueryData
);
})
);

Expand Down
Loading

0 comments on commit 9dc81b9

Please sign in to comment.