Skip to content

Commit

Permalink
UI-bug fixes, added create query for MV (#182) (#188)
Browse files Browse the repository at this point in the history
* fixed MV load bug, added mv create button, handled error case when post query async fails



* addressed pr commits



* changed the materialiazed view check



* changed badge to notif badge for mv



* type check for mv



* added label for mv, changed mv condition



---------


(cherry picked from commit be457f6)

Signed-off-by: sumukhswamy <sumukhhs@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>
  • Loading branch information
1 parent f96c5d9 commit 4187b6d
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 117 deletions.
25 changes: 19 additions & 6 deletions common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ export const TREE_ITEM_TABLE_NAME_DEFAULT_NAME = `table`;
export const TREE_ITEM_LOAD_MATERIALIZED_BADGE_NAME = `Load Materialized View`;
export const TREE_ITEM_BADGE_NAME = `badge`;
export const LOAD_OPENSEARCH_INDICES_QUERY = `SHOW tables LIKE '%';`;
export const SKIPPING_INDEX_QUERY = `CREATE SKIPPING INDEX ON myS3.logs_db.http_logs
export const SKIPPING_INDEX_QUERY = `CREATE SKIPPING INDEX ON datasource.database.table
(status VALUE_SET)
WITH (
auto_refresh = true
auto_refresh = true,
checkpoint_location = 's3://test/'
)`;
export const COVERING_INDEX_QUERY = `CREATE INDEX covering_idx ON myS3.logs_db.http_logs
export const COVERING_INDEX_QUERY = `CREATE INDEX covering_idx ON datasource.database.table
(status)
WITH (
auto_refresh = true
auto_refresh = true,
checkpoint_location = 's3://test/'
)`;
export const CREATE_DATABASE_QUERY = `CREATE DATABASE myS3.logs_db`;
export const CREATE_TABLE_QUERY = `CREATE EXTERNAL TABLE myS3.logs_db.logs (
export const CREATE_DATABASE_QUERY = `CREATE DATABASE datasource.database`;
export const CREATE_TABLE_QUERY = `CREATE EXTERNAL TABLE datasource.database.table (
key BIGINT,
status INTEGER,
size FLOAT,
Expand All @@ -42,6 +44,17 @@ OPTIONS (
compression 'gzip'
);`;

export const CREATE_MATERIALIZED_VIEW = `CREATE MATERIALIZED VIEW datasource.database.materialized_view
AS SELECT
count(field)
FROM datasource.database.table
GROUP BY TUMBLE (timestamp, '2 hours')
WITH (
auto_refresh = true,
watermark_delay = '2 minutes',
checkpoint_location = 's3://test/'
)`;

export const ACCELERATION_INDEX_TYPES = [
{ label: 'Skipping Index', value: 'skipping' },
{ label: 'Covering Index', value: 'covering' },
Expand Down
3 changes: 3 additions & 0 deletions common/utils/async_query_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export const getJobId = (query: {}, http: CoreStart['http'], callback) => {
.then((res) => {
const id = res.data.resp.queryId;
setAsyncSessionId(_.get(res.data.resp, 'sessionId', null));
if (id === undefined) {
console.error(JSON.parse(res.data.body));
}
callback(id);
})
.catch((err) => {
Expand Down
19 changes: 18 additions & 1 deletion public/components/SQLPage/CreateButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import React, { useState } from 'react';
import {
COVERING_INDEX_QUERY,
CREATE_DATABASE_QUERY,
CREATE_MATERIALIZED_VIEW,
CREATE_TABLE_QUERY,
SKIPPING_INDEX_QUERY,
SKIPPING_INDEX_QUERY
} from '../../../common/constants';

interface CreateButtonProps {
Expand Down Expand Up @@ -57,6 +58,13 @@ export const CreateButton = ({ updateSQLQueries, selectedDatasource }: CreateBut
},
];

const materializedViewItems = [
{
name: 'Materialized View',
onClick: () => handleSubMenuClick(CREATE_MATERIALIZED_VIEW),
},
];

const button = (
<EuiButton iconType="arrowDown" iconSide="right" onClick={() => togglePopover(null)}>
Create
Expand Down Expand Up @@ -88,6 +96,10 @@ export const CreateButton = ({ updateSQLQueries, selectedDatasource }: CreateBut
name: 'Acceleration Index',
panel: 2,
},
{
name: 'Materialized View',
panel: 3,
}
],
},
{
Expand All @@ -100,6 +112,11 @@ export const CreateButton = ({ updateSQLQueries, selectedDatasource }: CreateBut
title: 'Acceleration Index Options',
items: acceleratedIndexItems,
},
{
id: 3,
title: 'Create Materialized View',
items: materializedViewItems,
},
]}
/>
</EuiPopover>
Expand Down
Loading

0 comments on commit 4187b6d

Please sign in to comment.