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

feat: extend alter table query templates with enable auto split #1913

Merged
merged 1 commit into from
Feb 6, 2025
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
2 changes: 2 additions & 0 deletions src/containers/Tenant/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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...",
Expand Down
16 changes: 14 additions & 2 deletions src/containers/Tenant/utils/schemaActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
dropTableTemplate,
dropTopicTemplate,
dropViewTemplate,
manageAutoPartitioningTemplate,
selectQueryTemplate,
upsertQueryTemplate,
} from './schemaQueryTemplates';
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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];
Expand All @@ -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'),
Expand All @@ -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},
Expand Down
15 changes: 15 additions & 0 deletions src/containers/Tenant/utils/schemaQueryTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:<my_table>}';

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:<my_table>}';
const columns =
Expand Down
Loading