From 6cb3e2b65bd8ed3d9de723fa03ce33848c3f7f05 Mon Sep 17 00:00:00 2001 From: Hellen Date: Fri, 28 Jun 2024 14:42:25 +0300 Subject: [PATCH] feat: add "Create column table" action (#957) --- src/containers/Tenant/i18n/en.json | 1 + src/containers/Tenant/utils/queryTemplates.ts | 12 ++++++++++++ src/containers/Tenant/utils/schemaActions.ts | 3 +++ 3 files changed, 16 insertions(+) diff --git a/src/containers/Tenant/i18n/en.json b/src/containers/Tenant/i18n/en.json index 49d2366ca..3be5439b8 100644 --- a/src/containers/Tenant/i18n/en.json +++ b/src/containers/Tenant/i18n/en.json @@ -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...", diff --git a/src/containers/Tenant/utils/queryTemplates.ts b/src/containers/Tenant/utils/queryTemplates.ts index 65b124dbe..a6958cbe4 100644 --- a/src/containers/Tenant/utils/queryTemplates.ts +++ b/src/containers/Tenant/utils/queryTemplates.ts @@ -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;`; diff --git a/src/containers/Tenant/utils/schemaActions.ts b/src/containers/Tenant/utils/schemaActions.ts index c693a4e8c..95aee7d3c 100644 --- a/src/containers/Tenant/utils/schemaActions.ts +++ b/src/containers/Tenant/utils/schemaActions.ts @@ -11,6 +11,7 @@ import i18n from '../i18n'; import { alterTableTemplate, alterTopicTemplate, + createColumnTableTemplate, createExternalTableTemplate, createTableTemplate, createTopicTemplate, @@ -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), @@ -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}, ],