Skip to content

Commit

Permalink
Add materlized views, manual refresh option and minor fixes (#159)
Browse files Browse the repository at this point in the history
* enable materialized views, update acc btn fill

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* update acceleration links

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* add manual refresh option, update tests

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* update copy for datasources

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

* fix redirection issue

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>

---------

Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>
  • Loading branch information
ps48 authored Oct 18, 2023
1 parent 8409ef7 commit 43b085b
Show file tree
Hide file tree
Showing 14 changed files with 251 additions and 77 deletions.
8 changes: 5 additions & 3 deletions common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

export const PLUGIN_ID = 'queryWorkbenchDashboards';
export const PLUGIN_NAME = 'Query Workbench';
export const OPENSEARCH_ACC_DOCUMENTATION_URL = 'https://opensearch.org/docs/latest';
export const ACC_INDEX_TYPE_DOCUMENTATION_URL = 'https://opensearch.org/docs/latest';
export const OPENSEARCH_ACC_DOCUMENTATION_URL =
'https://opensearch.org/docs/latest/dashboards/management/accelerate-external-data/';
export const ACC_INDEX_TYPE_DOCUMENTATION_URL =
'https://github.com/opensearch-project/opensearch-spark/blob/main/docs/index.md';

export const SKIPPING_INDEX = `skipping_index`;
export const ON_LOAD_QUERY = `SHOW tables LIKE '%';`;
Expand Down Expand Up @@ -37,7 +39,7 @@ OPTIONS (
export const ACCELERATION_INDEX_TYPES = [
{ label: 'Skipping Index', value: 'skipping' },
{ label: 'Covering Index', value: 'covering' },
// { label: 'Materialized View', value: 'materialized' }, Hidden Option -> Until opensearch-spark feature is ready
{ label: 'Materialized View', value: 'materialized' },
];

export const ACCELERATION_AGGREGRATION_FUNCTIONS = [
Expand Down
6 changes: 4 additions & 2 deletions common/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export interface FormErrorsType {
checkpointLocationError: string[];
}

export type AccelerationRefreshType = 'auto' | 'interval' | 'manual';

export interface CreateAccelerationForm {
dataSource: string;
database: string;
Expand All @@ -71,10 +73,10 @@ export interface CreateAccelerationForm {
accelerationIndexName: string;
primaryShardsCount: number;
replicaShardsCount: number;
refreshType: 'interval' | 'auto';
refreshType: AccelerationRefreshType;
checkpointLocation: string | undefined;
refreshIntervalOptions: RefreshIntervalType;
formErrors: FormErrorsType;
}

export type AsyncQueryLoadingStatus = "SUCCESS" | "FAILED" | "RUNNING" | "SCHEDULED" | "CANCELED"
export type AsyncQueryLoadingStatus = 'SUCCESS' | 'FAILED' | 'RUNNING' | 'SCHEDULED' | 'CANCELED';
14 changes: 13 additions & 1 deletion public/components/Main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ interface MainState {
asyncLoading: boolean;
asyncLoadingStatus: AsyncQueryLoadingStatus;
asyncJobId: string;
isAccelerationFlyoutOpened: boolean;
}

const SUCCESS_MESSAGE = 'Success';
Expand Down Expand Up @@ -246,6 +247,7 @@ export class Main extends React.Component<MainProps, MainState> {
asyncLoading: false,
asyncLoadingStatus: 'SUCCESS',
asyncJobId: '',
isAccelerationFlyoutOpened: false,
};
this.httpClient = this.props.httpClient;
this.updateSQLQueries = _.debounce(this.updateSQLQueries, 250).bind(this);
Expand Down Expand Up @@ -789,7 +791,7 @@ export class Main extends React.Component<MainProps, MainState> {
});
}

handleDataSelect = (selectedItems: []) => {
handleDataSelect = (selectedItems: EuiComboBoxOptionOption[]) => {
if (selectedItems[0].label !== 'OpenSearch' && this.state.language === 'SQL') {
this.updateSQLQueries('');
}
Expand All @@ -798,6 +800,12 @@ export class Main extends React.Component<MainProps, MainState> {
});
};

setIsAccelerationFlyoutOpened = (value: boolean) => {
this.setState({
isAccelerationFlyoutOpened: value,
});
};

render() {
let page;
let link;
Expand All @@ -819,6 +827,10 @@ export class Main extends React.Component<MainProps, MainState> {
updateSQLQueries={this.updateSQLQueries}
selectedDatasource={this.state.selectedDatasource}
asyncLoading={this.state.asyncLoading}
openAccelerationFlyout={
this.props.isAccelerationFlyoutOpen && !this.state.isAccelerationFlyoutOpened
}
setIsAccelerationFlyoutOpened={this.setIsAccelerationFlyoutOpened}
/>
);
link = 'https://opensearch.org/docs/latest/search-plugins/sql/index/';
Expand Down
18 changes: 17 additions & 1 deletion public/components/SQLPage/SQLPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ interface SQLPageProps {
sqlTranslations: ResponseDetail<TranslateResult>[];
selectedDatasource: EuiComboBoxOptionOption[];
asyncLoading: boolean;
openAccelerationFlyout: boolean;
setIsAccelerationFlyoutOpened: (value: boolean) => void;
}

interface SQLPageState {
Expand Down Expand Up @@ -80,6 +82,21 @@ export class SQLPage extends React.Component<SQLPageProps, SQLPageState> {
});
};

componentDidUpdate(prevProps: SQLPageProps) {
const { selectedDatasource, openAccelerationFlyout } = this.props;
const prevDataSource = prevProps.selectedDatasource[0].label;
const currentDataSource = selectedDatasource[0].label;

if (
currentDataSource !== prevDataSource &&
currentDataSource !== 'OpenSearch' &&
openAccelerationFlyout
) {
this.setAccelerationFlyout();
this.props.setIsAccelerationFlyoutOpened(true);
}
}

render() {
const closeModal = () => this.setIsModalVisible(false);
const showModal = () => this.setIsModalVisible(true);
Expand Down Expand Up @@ -187,7 +204,6 @@ export class SQLPage extends React.Component<SQLPageProps, SQLPageState> {
this.props.selectedDatasource[0].label !== 'OpenSearch' && (
<EuiFlexItem grow={false}>
<EuiButton
fill={true}
className="sql-accelerate-button"
onClick={this.setAccelerationFlyout}
isDisabled={this.props.asyncLoading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Array [
<a
class="euiLink euiLink--primary"
href="https://opensearch.org/docs/latest"
href="https://opensearch.org/docs/latest/dashboards/management/accelerate-external-data/"
rel="noopener noreferrer"
target="_blank"
>
Expand Down Expand Up @@ -132,7 +132,7 @@ Array [
<div
class="euiTextColor euiTextColor--subdued"
>
Select data connection where the data you want to accelerate resides.
Select the data source to accelerate data from. External data sources may take time to load.
</div>
</div>
<div
Expand Down Expand Up @@ -441,7 +441,7 @@ Array [
>
<a
class="euiLink euiLink--primary"
href="https://opensearch.org/docs/latest"
href="https://github.com/opensearch-project/opensearch-spark/blob/main/docs/index.md"
rel="noopener noreferrer"
target="_blank"
>
Expand Down Expand Up @@ -670,7 +670,7 @@ Array [
class="euiRadio__label"
for="refresh-option-1"
>
Auto Refresh
Auto refresh
</label>
</div>
<div
Expand All @@ -690,15 +690,35 @@ Array [
class="euiRadio__label"
for="refresh-option-2"
>
Refresh by interval
Auto refresh by interval
</label>
</div>
<div
class="euiRadio euiRadioGroup__item"
>
<input
class="euiRadio__input"
id="refresh-option-3"
name="refresh type radio group"
type="radio"
value=""
/>
<div
class="euiRadio__circle"
/>
<label
class="euiRadio__label"
for="refresh-option-3"
>
Manual refresh
</label>
</div>
</div>
<div
class="euiFormHelpText euiFormRow__text"
id="some_html_id-help-0"
>
Specify how often the index should refresh, which publishes the most recent changes and make them available for search. Default is set to auto refresh when data at the source changes.
Specify how often the index should refresh, which publishes the most recent changes and make them available for search.
</div>
</div>
</div>
Expand Down Expand Up @@ -1181,7 +1201,7 @@ Array [
<a
className="euiLink euiLink--primary"
href="https://opensearch.org/docs/latest"
href="https://opensearch.org/docs/latest/dashboards/management/accelerate-external-data/"
rel="noopener noreferrer"
target="_blank"
>
Expand Down Expand Up @@ -1243,7 +1263,7 @@ Array [
<div
className="euiTextColor euiTextColor--subdued"
>
Select data connection where the data you want to accelerate resides.
Select the data source to accelerate data from. External data sources may take time to load.
</div>
</div>,
<div
Expand Down Expand Up @@ -1635,7 +1655,7 @@ Array [
>
<a
className="euiLink euiLink--primary"
href="https://opensearch.org/docs/latest"
href="https://github.com/opensearch-project/opensearch-spark/blob/main/docs/index.md"
rel="noopener noreferrer"
target="_blank"
>
Expand Down Expand Up @@ -1900,7 +1920,7 @@ Array [
className="euiRadio__label"
htmlFor="refresh-option-1"
>
Auto Refresh
Auto refresh
</label>
</div>
<div
Expand All @@ -1921,15 +1941,36 @@ Array [
className="euiRadio__label"
htmlFor="refresh-option-2"
>
Refresh by interval
Auto refresh by interval
</label>
</div>
<div
className="euiRadio euiRadioGroup__item"
>
<input
checked={false}
className="euiRadio__input"
id="refresh-option-3"
name="refresh type radio group"
onChange={[Function]}
type="radio"
/>
<div
className="euiRadio__circle"
/>
<label
className="euiRadio__label"
htmlFor="refresh-option-3"
>
Manual refresh
</label>
</div>
</div>
<div
className="euiFormHelpText euiFormRow__text"
id="some_html_id-help-0"
>
Specify how often the index should refresh, which publishes the most recent changes and make them available for search. Default is set to auto refresh when data at the source changes.
Specify how often the index should refresh, which publishes the most recent changes and make them available for search.
</div>
</div>
</div>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports[`Acceleration header renders acceleration flyout header 1`] = `
<a
className="euiLink euiLink--primary"
href="https://opensearch.org/docs/latest"
href="https://opensearch.org/docs/latest/dashboards/management/accelerate-external-data/"
rel="noopener noreferrer"
target="_blank"
>
Expand Down
Loading

0 comments on commit 43b085b

Please sign in to comment.