Skip to content

Commit

Permalink
feat: add "Create column table" action (#957)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raubzeug authored Jun 28, 2024
1 parent 99a24ce commit 6cb3e2b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/containers/Tenant/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"actions.createTable": "Create table...",
"actions.createExternalTable": "Create external table...",
"actions.createTopic": "Create topic...",
"actions.createColumnTable": "Create column table...",
"actions.createView": "Create view...",
"actions.dropTable": "Drop table...",
"actions.dropTopic": "Drop topic...",
Expand Down
12 changes: 12 additions & 0 deletions src/containers/Tenant/utils/queryTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ WITH (
-- if some keys are missing in a table when making multiple single queries by the primary key.
)`;
};
export const createColumnTableTemplate = (path: string) => {
return `-- docs: https://ydb.tech/en/docs/yql/reference/syntax/create_table#olap-tables
CREATE TABLE \`${path}/ydb_column_table\` (
id Int64 NOT NULL,
author Text,
title Text,
body Text,
PRIMARY KEY (id)
)
PARTITION BY HASH(id)
WITH (STORE = COLUMN)`;
};
export const alterTableTemplate = (path: string) => {
return `ALTER TABLE \`${path}\`
ADD COLUMN is_deleted Bool;`;
Expand Down
3 changes: 3 additions & 0 deletions src/containers/Tenant/utils/schemaActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import i18n from '../i18n';
import {
alterTableTemplate,
alterTopicTemplate,
createColumnTableTemplate,
createExternalTableTemplate,
createTableTemplate,
createTopicTemplate,
Expand Down Expand Up @@ -47,6 +48,7 @@ const bindActions = (

return {
createTable: inputQuery(createTableTemplate, 'script'),
createColumnTable: inputQuery(createColumnTableTemplate, 'script'),
alterTable: inputQuery(alterTableTemplate, 'script'),
selectQuery: inputQuery(selectQueryTemplate),
upsertQuery: inputQuery(upsertQueryTemplate),
Expand Down Expand Up @@ -89,6 +91,7 @@ export const getActions =
[copyItem],
[
{text: i18n('actions.createTable'), action: actions.createTable},
{text: i18n('actions.createColumnTable'), action: actions.createColumnTable},
{text: i18n('actions.createTopic'), action: actions.createTopic},
{text: i18n('actions.createView'), action: actions.createView},
],
Expand Down

0 comments on commit 6cb3e2b

Please sign in to comment.