diff --git a/src/containers/Tenant/i18n/en.json b/src/containers/Tenant/i18n/en.json index b36c217d8a..399969a2ed 100644 --- a/src/containers/Tenant/i18n/en.json +++ b/src/containers/Tenant/i18n/en.json @@ -38,6 +38,8 @@ "actions.dropTopic": "Drop topic...", "actions.dropView": "Drop view...", "actions.alterTable": "Alter table...", + "actions.manageColumns": "Manage columns...", + "actions.manageAutoPartitioning": "Manage auto partitioning...", "actions.addTableIndex": "Add index...", "actions.createCdcStream": "Create changefeed...", "actions.alterTopic": "Alter topic...", diff --git a/src/containers/Tenant/utils/schemaActions.tsx b/src/containers/Tenant/utils/schemaActions.tsx index f7e0adab2e..46b1651a81 100644 --- a/src/containers/Tenant/utils/schemaActions.tsx +++ b/src/containers/Tenant/utils/schemaActions.tsx @@ -33,6 +33,7 @@ import { dropTableTemplate, dropTopicTemplate, dropViewTemplate, + manageAutoPartitioningTemplate, selectQueryTemplate, upsertQueryTemplate, } from './schemaQueryTemplates'; @@ -101,6 +102,7 @@ const bindActions = ( dropAsyncReplication: inputQuery(dropAsyncReplicationTemplate), alterTable: inputQuery(alterTableTemplate), dropTable: inputQuery(dropTableTemplate), + manageAutoPartitioning: inputQuery(manageAutoPartitioningTemplate), selectQuery: inputQuery(selectQueryTemplate), upsertQuery: inputQuery(upsertQueryTemplate), createExternalTable: inputQuery(createExternalTableTemplate), @@ -183,6 +185,16 @@ export const getActions = {text: i18n('actions.createView'), action: actions.createView}, ]; + const alterTableGroupItem = { + text: i18n('actions.alterTable'), + items: [ + {text: i18n('actions.manageColumns'), action: actions.alterTable}, + { + text: i18n('actions.manageAutoPartitioning'), + action: actions.manageAutoPartitioning, + }, + ], + }; const DB_SET: ActionsSet = [[copyItem, connectToDBItem], createEntitiesSet]; const DIR_SET: ActionsSet = [[copyItem], createEntitiesSet]; @@ -200,7 +212,7 @@ export const getActions = const ROW_TABLE_SET: ActionsSet = [ [copyItem], [ - {text: i18n('actions.alterTable'), action: actions.alterTable}, + alterTableGroupItem, {text: i18n('actions.dropTable'), action: actions.dropTable}, getActionWithLoader({ text: i18n('actions.selectQuery'), @@ -219,7 +231,7 @@ export const getActions = const COLUMN_TABLE_SET: ActionsSet = [ [copyItem], [ - {text: i18n('actions.alterTable'), action: actions.alterTable}, + alterTableGroupItem, {text: i18n('actions.dropTable'), action: actions.dropTable}, {text: i18n('actions.selectQuery'), action: actions.selectQuery}, {text: i18n('actions.upsertQuery'), action: actions.upsertQuery}, diff --git a/src/containers/Tenant/utils/schemaQueryTemplates.ts b/src/containers/Tenant/utils/schemaQueryTemplates.ts index e90f087265..a7f37672e6 100644 --- a/src/containers/Tenant/utils/schemaQueryTemplates.ts +++ b/src/containers/Tenant/utils/schemaQueryTemplates.ts @@ -84,6 +84,21 @@ ALTER TABLE ${path} -- DROP COLUMN some_existing_column \${2:ADD COLUMN numeric_column Int32};`; }; + +export const manageAutoPartitioningTemplate = (params?: SchemaQueryParams) => { + const path = params?.relativePath ? `\`${params?.relativePath}\`` : '${1:}'; + + return `-- documentation about partitioning https://ydb.tech/docs/en/concepts/datamodel/table#partitioning + +ALTER TABLE ${path} SET +( + AUTO_PARTITIONING_BY_LOAD = ENABLED, -- If a partition consumes more than 50% of the CPU for a few dozens of seconds, it is enqueued for splitting. + AUTO_PARTITIONING_BY_SIZE = ENABLED, -- If a partition size exceeds the value specified by the AUTO_PARTITIONING_PARTITION_SIZE_MB parameter, it is enqueued for splitting. + AUTO_PARTITIONING_PARTITION_SIZE_MB = 2048, + AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 10, -- Partitions are merged only if their actual number exceeds the value specified by this parameter. + AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 100 -- Partitions are split only if their number doesn't exceed the value specified by this parameter. +)`; +}; export const selectQueryTemplate = (params?: SchemaQueryParams) => { const path = params?.relativePath ? `\`${params?.relativePath}\`` : '${2:}'; const columns =