Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.11] UI-bug fixes, added create query for MV #188

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading