Skip to content

Commit 6cb3e2b

Browse files
authored
feat: add "Create column table" action (#957)
1 parent 99a24ce commit 6cb3e2b

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/containers/Tenant/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"actions.createTable": "Create table...",
2020
"actions.createExternalTable": "Create external table...",
2121
"actions.createTopic": "Create topic...",
22+
"actions.createColumnTable": "Create column table...",
2223
"actions.createView": "Create view...",
2324
"actions.dropTable": "Drop table...",
2425
"actions.dropTopic": "Drop topic...",

src/containers/Tenant/utils/queryTemplates.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ WITH (
3030
-- if some keys are missing in a table when making multiple single queries by the primary key.
3131
)`;
3232
};
33+
export const createColumnTableTemplate = (path: string) => {
34+
return `-- docs: https://ydb.tech/en/docs/yql/reference/syntax/create_table#olap-tables
35+
CREATE TABLE \`${path}/ydb_column_table\` (
36+
id Int64 NOT NULL,
37+
author Text,
38+
title Text,
39+
body Text,
40+
PRIMARY KEY (id)
41+
)
42+
PARTITION BY HASH(id)
43+
WITH (STORE = COLUMN)`;
44+
};
3345
export const alterTableTemplate = (path: string) => {
3446
return `ALTER TABLE \`${path}\`
3547
ADD COLUMN is_deleted Bool;`;

src/containers/Tenant/utils/schemaActions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import i18n from '../i18n';
1111
import {
1212
alterTableTemplate,
1313
alterTopicTemplate,
14+
createColumnTableTemplate,
1415
createExternalTableTemplate,
1516
createTableTemplate,
1617
createTopicTemplate,
@@ -47,6 +48,7 @@ const bindActions = (
4748

4849
return {
4950
createTable: inputQuery(createTableTemplate, 'script'),
51+
createColumnTable: inputQuery(createColumnTableTemplate, 'script'),
5052
alterTable: inputQuery(alterTableTemplate, 'script'),
5153
selectQuery: inputQuery(selectQueryTemplate),
5254
upsertQuery: inputQuery(upsertQueryTemplate),
@@ -89,6 +91,7 @@ export const getActions =
8991
[copyItem],
9092
[
9193
{text: i18n('actions.createTable'), action: actions.createTable},
94+
{text: i18n('actions.createColumnTable'), action: actions.createColumnTable},
9295
{text: i18n('actions.createTopic'), action: actions.createTopic},
9396
{text: i18n('actions.createView'), action: actions.createView},
9497
],

0 commit comments

Comments
 (0)