From 8fc30bb1325927422beca5cc376a2ef5235aab9a Mon Sep 17 00:00:00 2001 From: Anton Standrik Date: Wed, 18 Sep 2024 16:05:50 +0300 Subject: [PATCH 1/2] fix: long running query test --- tests/suites/tenant/queryEditor/constants.ts | 31 ++------------------ 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/tests/suites/tenant/queryEditor/constants.ts b/tests/suites/tenant/queryEditor/constants.ts index 3238b159c..be9ca373c 100644 --- a/tests/suites/tenant/queryEditor/constants.ts +++ b/tests/suites/tenant/queryEditor/constants.ts @@ -1,32 +1,7 @@ // Long running query for tests // May cause Memory exceed on real database -export const longRunningQuery = ` -PRAGMA TablePathPrefix(""); +const simpleQuery = 'SELECT 1;'; -SELECT COUNT(*) AS total_count -FROM ( - SELECT 1 AS dummy - FROM - (SELECT 1 AS d UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL - SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1) AS t1 - CROSS JOIN - (SELECT 1 AS d UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL - SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1) AS t2 - CROSS JOIN - (SELECT 1 AS d UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL - SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1) AS t3 - CROSS JOIN - (SELECT 1 AS d UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL - SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1) AS t4 - CROSS JOIN - (SELECT 1 AS d UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL - SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1) AS t5 - CROSS JOIN - (SELECT 1 AS d UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL - SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1) AS t6 - CROSS JOIN - (SELECT 1 AS d UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL - SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1) AS t7 -) AS large_table - `; +// 400 is pretty enough +export const longRunningQuery = new Array(400).fill(simpleQuery).join(''); From 163583cbc0b2e8eb957767c63c3f3c7b48745c28 Mon Sep 17 00:00:00 2001 From: Anton Standrik Date: Fri, 20 Sep 2024 15:57:48 +0300 Subject: [PATCH 2/2] feat: move query templates to a hierarchical menu at query editor --- src/containers/Tenant/Query/NewSQL/NewSQL.tsx | 151 +++++++++++ .../Tenant/Query/NewSQL/i18n/en.json | 32 +++ .../Tenant/Query/NewSQL/i18n/index.ts | 7 + .../QueryEditorControls.scss | 1 + .../QueryEditorControls.tsx | 6 +- .../Tenant/utils/newSQLQueryActions.ts | 62 +++++ .../Tenant/utils/newSQLQueryTemplates.ts | 250 ++++++++++++++++++ src/containers/Tenant/utils/schemaActions.ts | 2 +- ...ryTemplates.ts => schemaQueryTemplates.ts} | 0 9 files changed, 509 insertions(+), 2 deletions(-) create mode 100644 src/containers/Tenant/Query/NewSQL/NewSQL.tsx create mode 100644 src/containers/Tenant/Query/NewSQL/i18n/en.json create mode 100644 src/containers/Tenant/Query/NewSQL/i18n/index.ts create mode 100644 src/containers/Tenant/utils/newSQLQueryActions.ts create mode 100644 src/containers/Tenant/utils/newSQLQueryTemplates.ts rename src/containers/Tenant/utils/{queryTemplates.ts => schemaQueryTemplates.ts} (100%) diff --git a/src/containers/Tenant/Query/NewSQL/NewSQL.tsx b/src/containers/Tenant/Query/NewSQL/NewSQL.tsx new file mode 100644 index 000000000..814c915ef --- /dev/null +++ b/src/containers/Tenant/Query/NewSQL/NewSQL.tsx @@ -0,0 +1,151 @@ +import {ChevronDown} from '@gravity-ui/icons'; +import {Button, DropdownMenu} from '@gravity-ui/uikit'; + +import {useTypedDispatch} from '../../../../utils/hooks'; +import {bindActions} from '../../utils/newSQLQueryActions'; + +import i18n from './i18n'; + +export function NewSQL() { + const dispatch = useTypedDispatch(); + const actions = bindActions(dispatch); + + const items = [ + { + text: i18n('menu.tables'), + items: [ + { + text: i18n('action.create-row-table'), + action: actions.createRowTable, + }, + { + text: i18n('action.create-column-table'), + action: actions.createColumnTable, + }, + { + text: i18n('action.create-external-table'), + action: actions.createExternalTable, + }, + { + text: i18n('action.upsert-to-table'), + action: actions.upsertQuery, + }, + { + text: i18n('action.update-table'), + action: actions.updateTable, + }, + { + text: i18n('action.alter-table'), + action: actions.alterTable, + }, + { + text: i18n('action.select-rows'), + action: actions.selectQuery, + }, + { + text: i18n('action.select-from-external-table'), + action: actions.selectQueryFromExternalTable, + }, + { + text: i18n('action.delete-rows'), + action: actions.deleteRows, + }, + { + text: i18n('action.drop-table'), + action: actions.dropTable, + }, + { + text: i18n('action.drop-external-table'), + action: actions.dropExternalTable, + }, + ], + }, + { + text: i18n('menu.topics'), + items: [ + { + text: i18n('action.create-topic'), + action: actions.createTopic, + }, + { + text: i18n('action.alter-topic'), + action: actions.alterTopic, + }, + { + text: i18n('action.drop-topic'), + action: actions.dropTopic, + }, + ], + }, + { + text: i18n('menu.replication'), + items: [ + { + text: i18n('action.create-async-replication'), + action: actions.createAsyncReplication, + }, + { + text: i18n('action.alter-async-replication'), + action: actions.alterAsyncReplication, + }, + { + text: i18n('action.drop-async-replication'), + action: actions.dropAsyncReplication, + }, + ], + }, + { + text: i18n('menu.capture'), + items: [ + { + text: i18n('action.create-cdc-stream'), + action: actions.createCdcStream, + }, + ], + }, + { + text: i18n('menu.users'), + items: [ + { + text: i18n('action.create-user'), + action: actions.createUser, + }, + { + text: i18n('action.create-group'), + action: actions.createGroup, + }, + { + text: i18n('action.drop-user'), + action: actions.dropUser, + }, + { + text: i18n('action.drop-group'), + action: actions.dropGroup, + }, + { + text: i18n('action.grant-privilege'), + action: actions.grantPrivilege, + }, + { + text: i18n('action.revoke-privilege'), + action: actions.revokePrivilege, + }, + ], + }, + ]; + + return ( + ( + + )} + popupProps={{placement: 'top'}} + /> + ); +} diff --git a/src/containers/Tenant/Query/NewSQL/i18n/en.json b/src/containers/Tenant/Query/NewSQL/i18n/en.json new file mode 100644 index 000000000..ffd5682bb --- /dev/null +++ b/src/containers/Tenant/Query/NewSQL/i18n/en.json @@ -0,0 +1,32 @@ +{ + "button.new-sql": "New SQL", + "action.create-row-table": "Create row table", + "action.create-column-table": "Create column table", + "action.create-external-table": "Create external table", + "action.upsert-to-table": "Upsert into table", + "action.update-table": "Update table", + "action.alter-table": "Alter table", + "action.select-rows": "Select from a table", + "action.select-from-external-table": "Select from external table", + "action.delete-rows": "Delete rows", + "action.drop-table": "Drop table", + "action.drop-external-table": "Drop external table", + "menu.tables": "Tables", + "menu.topics": "Topics", + "menu.capture": "Change data capture", + "menu.replication": "Async replication", + "menu.users": "Users", + "action.create-topic": "Create Topic", + "action.drop-topic": "Drop Topic", + "action.alter-topic": "Alter Topic", + "action.create-cdc-stream": "Create CDC Stream", + "action.create-async-replication": "Create async replication", + "action.create-user": "Create user", + "action.create-group": "Create group", + "action.drop-user": "Drop user", + "action.drop-group": "Drop group", + "action.grant-privilege": "Grant privilege", + "action.revoke-privilege": "Revoke privilege", + "action.alter-async-replication": "Alter async replication", + "action.drop-async-replication": "Drop async replication" +} diff --git a/src/containers/Tenant/Query/NewSQL/i18n/index.ts b/src/containers/Tenant/Query/NewSQL/i18n/index.ts new file mode 100644 index 000000000..394092c3f --- /dev/null +++ b/src/containers/Tenant/Query/NewSQL/i18n/index.ts @@ -0,0 +1,7 @@ +import {registerKeysets} from '../../../../../utils/i18n'; + +import en from './en.json'; + +const COMPONENT = 'ydb-new-sql'; + +export default registerKeysets(COMPONENT, {en}); diff --git a/src/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.scss b/src/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.scss index 4241d69f9..4821b8ec2 100644 --- a/src/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.scss +++ b/src/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.scss @@ -8,6 +8,7 @@ min-height: 40px; padding: 5px 0px; + &__right, &__left { display: flex; gap: 12px; diff --git a/src/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.tsx b/src/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.tsx index 97ae967a8..64d252c95 100644 --- a/src/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.tsx +++ b/src/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.tsx @@ -6,6 +6,7 @@ import QuerySettingsDescription from '../../../../components/QuerySettingsDescri import type {QueryAction} from '../../../../types/store/query'; import {cn} from '../../../../utils/cn'; import {useChangedQuerySettings} from '../../../../utils/hooks/useChangedQuerySettings'; +import {NewSQL} from '../NewSQL/NewSQL'; import {SaveQuery} from '../SaveQuery/SaveQuery'; import i18n from '../i18n'; @@ -107,7 +108,10 @@ export const QueryEditorControls = ({ - +
+ + +
); }; diff --git a/src/containers/Tenant/utils/newSQLQueryActions.ts b/src/containers/Tenant/utils/newSQLQueryActions.ts new file mode 100644 index 000000000..d20ff5423 --- /dev/null +++ b/src/containers/Tenant/utils/newSQLQueryActions.ts @@ -0,0 +1,62 @@ +import {changeUserInput} from '../../../store/reducers/executeQuery'; + +import { + alterAsyncReplicationTemplate, + alterTableTemplate, + alterTopicTemplate, + createAsyncReplicationTemplate, + createCdcStreamTemplate, + createColumnTableTemplate, + createExternalTableTemplate, + createGroupTemplate, + createTableTemplate, + createTopicTemplate, + createUserTemplate, + createViewTemplate, + deleteRowsTemplate, + dropAsyncReplicationTemplate, + dropExternalTableTemplate, + dropGroupTemplate, + dropTableTemplate, + dropTopicTemplate, + dropUserTemplate, + grantPrivilegeTemplate, + revokePrivilegeTemplate, + selectQueryTemplate, + updateTableTemplate, + upsertQueryTemplate, +} from './newSQLQueryTemplates'; + +export const bindActions = (dispatch: React.Dispatch) => { + const inputQuery = (query: () => string) => () => { + dispatch(changeUserInput({input: query()})); + }; + + return { + createRowTable: inputQuery(createTableTemplate), + createColumnTable: inputQuery(createColumnTableTemplate), + createAsyncReplication: inputQuery(createAsyncReplicationTemplate), + alterAsyncReplication: inputQuery(alterAsyncReplicationTemplate), + dropAsyncReplication: inputQuery(dropAsyncReplicationTemplate), + alterTable: inputQuery(alterTableTemplate), + selectQuery: inputQuery(selectQueryTemplate), + upsertQuery: inputQuery(upsertQueryTemplate), + createExternalTable: inputQuery(createExternalTableTemplate), + dropExternalTable: inputQuery(dropExternalTableTemplate), + selectQueryFromExternalTable: inputQuery(selectQueryTemplate), + createTopic: inputQuery(createTopicTemplate), + alterTopic: inputQuery(alterTopicTemplate), + dropTopic: inputQuery(dropTopicTemplate), + createView: inputQuery(createViewTemplate), + dropTable: inputQuery(dropTableTemplate), + deleteRows: inputQuery(deleteRowsTemplate), + updateTable: inputQuery(updateTableTemplate), + createUser: inputQuery(createUserTemplate), + createGroup: inputQuery(createGroupTemplate), + createCdcStream: inputQuery(createCdcStreamTemplate), + grantPrivilege: inputQuery(grantPrivilegeTemplate), + revokePrivilege: inputQuery(revokePrivilegeTemplate), + dropUser: inputQuery(dropUserTemplate), + dropGroup: inputQuery(dropGroupTemplate), + }; +}; diff --git a/src/containers/Tenant/utils/newSQLQueryTemplates.ts b/src/containers/Tenant/utils/newSQLQueryTemplates.ts new file mode 100644 index 000000000..20f59fab0 --- /dev/null +++ b/src/containers/Tenant/utils/newSQLQueryTemplates.ts @@ -0,0 +1,250 @@ +export const createTableTemplate = () => { + return `-- docs: https://ydb.tech/en/docs/yql/reference/syntax/create_table +CREATE TABLE \`$path\` ( + category_id Uint64 NOT NULL, + id Uint64, + expire_at Datetime, + updated_on Datetime, + name Text, + \`binary-payload\` Bytes, + attributes JsonDocument, + -- uncomment to add a secondary index + -- INDEX idx_row_table_id GLOBAL SYNC ON ( id ) COVER ( name, attributes ), -- Secondary indexes docs https://ydb.tech/en/docs/yql/reference/syntax/create_table#secondary_index + PRIMARY KEY (category_id, id) +) +WITH ( + AUTO_PARTITIONING_BY_SIZE=\`$autoPartitioningBySize\`, + AUTO_PARTITIONING_PARTITION_SIZE_MB=\`$autoPartitioningPartitionSizeMb\`, + AUTO_PARTITIONING_BY_LOAD=\`$autoPartitioningByLoad\`, + AUTO_PARTITIONING_MIN_PARTITIONS_COUNT=\`$autoPartitioningMinPartitionsCount\`, + AUTO_PARTITIONING_MAX_PARTITIONS_COUNT=\`$autoPartitioningMaxPartitionsCount\` + -- uncomment to create a table with predefined partitions + -- , UNIFORM_PARTITIONS=\`$uniformPartitions\` -- The number of partitions for uniform initial table partitioning. + -- The primary key's first column must have type Uint64 or Uint32. + -- A created table is immediately divided into the specified number of partitions + -- uncomment to launch read only replicas in every AZ + -- , READ_REPLICAS_SETTINGS=\`$readReplicasSettings\` -- Enable read replicas for stale read, launch one replica in every availability zone + -- uncomment to enable ttl + -- , TTL=\`$ttl\` ON expire_at -- Enable background deletion of expired rows https://ydb.tech/en/docs/concepts/ttl + -- uncomment to create a table with a bloom filter + -- , KEY_BLOOM_FILTER=\`$keyBloomFilter\` -- With a Bloom filter, you can more efficiently determine + -- if some keys are missing in a table when making multiple single queries by the primary key. +)`; +}; + +export const createColumnTableTemplate = () => { + return `-- docs: https://ydb.tech/en/docs/yql/reference/syntax/create_table#olap-tables +CREATE TABLE \`$path\` ( + id Int64 NOT NULL, + author Text, + title Text, + body Text, + PRIMARY KEY (id) +) +PARTITION BY HASH(id) +WITH (STORE=\`$store\`)`; +}; + +export const deleteRowsTemplate = () => { + return `-- docs: https://ydb.tech/docs/en/yql/reference/syntax/delete +DELETE FROM $path +WHERE Key1 == $key1 AND Key2 >= $key2;`; +}; + +export const updateTableTemplate = () => { + return `-- docs: https://ydb.tech/docs/en/yql/reference/syntax/update +UPDATE my_table +SET Value1 = YQL::ToString($value2 + 1), Value2 = $value2 - 1 +WHERE Key1 > $key1;`; +}; + +export const createUserTemplate = () => { + return `-- docs: https://ydb.tech/docs/en/yql/reference/syntax/create-user +CREATE USER $user_name [option] +-- user_name: The name of the user. It may contain lowercase Latin letters and digits. +-- option: The password of the user: + -- PASSWORD 'password' creates a user with the password password. The ENCRYPTED option is always enabled. + -- PASSWORD NULL creates a user with an empty password.`; +}; + +export const createGroupTemplate = () => { + return `-- docs: https://ydb.tech/docs/en/yql/reference/syntax/create-group +CREATE GROUP $group_name +-- group_name: The name of the group. It may contain lowercase Latin letters and digits.`; +}; + +export const createAsyncReplicationTemplate = () => { + return `CREATE OBJECT secret_name (TYPE SECRET) WITH value=\`$secretValue\`; + +CREATE ASYNC REPLICATION my_replication +FOR \`$remotePath\` AS \`$localTableName\` --[, \`$anotherRemotePath\` AS \`$anotherLocalTableName\` ...] +WITH ( + CONNECTION_STRING=\`$connectionString\`, + TOKEN_SECRET_NAME=\`$tokenSecretName\` + -- ENDPOINT=\`$endpoint\`, + -- DATABASE=\`$database\`, + -- USER=\`$user\`, + -- PASSWORD_SECRET_NAME=\`$passwordSecretName\` +);`; +}; + +export const alterTableTemplate = () => { + return `ALTER TABLE \`$path\` + ADD COLUMN numeric_column Int32;`; +}; + +export const selectQueryTemplate = () => { + return `SELECT * + FROM \`$path\` + LIMIT 10;`; +}; + +export const upsertQueryTemplate = () => { + return `UPSERT INTO \`$path\` + ( \`id\`, \`name\` ) +VALUES ( );`; +}; + +export const dropExternalTableTemplate = () => { + return `DROP EXTERNAL TABLE \`$path\`;`; +}; + +export const dropUserTemplate = () => { + return `-- docs: https://ydb.tech/docs/en/yql/reference/syntax/drop-user +DROP USER [ IF EXISTS ] $user_name [, ...] + +-- IF EXISTS: Suppress an error if the user doesn't exist. +-- user_name: The name of the user to be deleted.`; +}; + +export const dropGroupTemplate = () => { + return `-- docs: https://ydb.tech/docs/en/yql/reference/syntax/drop-group +DROP GROUP [ IF EXISTS ] $group_name [, ...] + +-- IF EXISTS: Suppress an error if the group doesn't exist. +-- group_name: The name of the group to be deleted.`; +}; + +export const createCdcStreamTemplate = () => { + return `-- docs: https://ydb.tech/docs/en/yql/reference/syntax/create_changefeed +ADD CHANGEFEED $name WITH ( + MODE = $mode, -- KEYS_ONLY, UPDATES, NEW_IMAGE, OLD_IMAGE, or NEW_AND_OLD_IMAGES + FORMAT = $format, -- JSON or DEBEZIUM_JSON + VIRTUAL_TIMESTAMPS = $virtualTimestamps, -- true or false + RETENTION_PERIOD = $retentionPeriod, -- Interval value, e.g., Interval('PT24H') + TOPIC_MIN_ACTIVE_PARTITIONS = $topicMinActivePartitions, + INITIAL_SCAN = $initialScan -- true or false +) + +-- MODE options: +-- KEYS_ONLY: Only the primary key components and change flag are written. +-- UPDATES: Updated column values that result from updates are written. +-- NEW_IMAGE: Any column values resulting from updates are written. +-- OLD_IMAGE: Any column values before updates are written. +-- NEW_AND_OLD_IMAGES: A combination of NEW_IMAGE and OLD_IMAGE modes.`; +}; + +export const grantPrivilegeTemplate = () => { + return ` +GRANT $permission_name [, ...] | ALL [PRIVILEGES] +ON $path_to_scheme_object [, ...] +TO $role_name [, ...] +[WITH GRANT OPTION] + +-- permission_name: The name of the access right to schema objects that needs to be assigned. +-- path_to_scheme_object: The path to the schema object for which rights are being granted. +-- role_name: The name of the user or group to whom rights on the schema object are being granted. +-- WITH GRANT OPTION: Using this construct gives the user or group of users the right to manage access rights - +-- to assign or revoke certain rights. This construct has functionality similar to granting +-- the "ydb.access.grant" or GRANT right. A subject with the ydb.access.grant right cannot +-- grant rights broader than they possess themselves.`; +}; + +export const revokePrivilegeTemplate = () => { + return ` +REVOKE [GRANT OPTION FOR] $permission_name [, ...] | ALL [PRIVILEGES] +ON $path_to_scheme_object [, ...] +FROM $role_name [, ...] + +-- permission_name: The name of the access right to schema objects that needs to be revoked. +-- path_to_scheme_object: The path to the schema object from which rights are being revoked. +-- role_name: The name of the user or group from whom rights on the schema object are being revoked. +-- GRANT OPTION FOR: Using this construct revokes the user's or group's right to manage access rights. +-- All previously granted rights by this user remain in effect. +-- This construct has functionality similar to revoking the "ydb.access.grant" or GRANT right.`; +}; + +export const createExternalTableTemplate = () => { + return `CREATE EXTERNAL TABLE \`$path\` ( + column1 Int, + column2 Int +) WITH ( + DATA_SOURCE=\`$dataSource\`, + LOCATION=\`$location\`, + FORMAT=\`$format\`, + \`file_pattern\`=\`$filePattern\` +);`; +}; + +export const createTopicTemplate = () => { + return `-- docs: https://ydb.tech/en/docs/yql/reference/syntax/create_topic +CREATE TOPIC \`$path\` ( + CONSUMER consumer1, + CONSUMER consumer2 WITH (read_from=\`$readFrom\`) -- Sets up the message write time starting from which the consumer will receive data. + -- Value type: Datetime OR Timestamp OR integer (unix-timestamp in the numeric format). + -- Default value: now +) WITH ( + min_active_partitions=\`$minActivePartitions\`, -- Minimum number of topic partitions. + partition_count_limit=\`$partitionCountLimit\`, -- Maximum number of active partitions in the topic. 0 is interpreted as unlimited. + retention_period=\`$retentionPeriod\`, -- Data retention period in the topic. Value type: Interval. + retention_storage_mb=\`$retentionStorageMb\`, -- Limit on the maximum disk space occupied by the topic data. + -- When this value is exceeded, the older data is cleared, like under a retention policy. + -- 0 is interpreted as unlimited. + partition_write_speed_bytes_per_second=\`$partitionWriteSpeedBytesPerSecond\`, -- Maximum allowed write speed per partition. + partition_write_burst_bytes=\`$partitionWriteBurstBytes\` -- Write quota allocated for write bursts. + -- When set to zero, the actual write_burst value is equalled to + -- the quota value (this allows write bursts of up to one second). +);`; +}; + +export const alterTopicTemplate = () => { + return `-- docs: https://ydb.tech/en/docs/yql/reference/syntax/alter_topic +ALTER TOPIC \`$path\` + ADD CONSUMER new_consumer WITH (read_from=\`$readFrom\`), -- Sets up the message write time starting from which the consumer will receive data. + -- Value type: Datetime OR Timestamp OR integer (unix-timestamp in the numeric format). + -- Default value: now + ALTER CONSUMER consumer1 SET (read_from=\`$readFrom\`), + DROP CONSUMER consumer2, + SET ( + min_active_partitions=\`$minActivePartitions\`, -- Minimum number of topic partitions. + partition_count_limit=\`$partitionCountLimit\`, -- Maximum number of active partitions in the topic. 0 is interpreted as unlimited. + retention_period=\`$retentionPeriod\`, -- Data retention period in the topic. Value type: Interval. + retention_storage_mb=\`$retentionStorageMb\`, -- Limit on the maximum disk space occupied by the topic data. + -- When this value is exceeded, the older data is cleared, like under a retention policy. + -- 0 is interpreted as unlimited. + partition_write_speed_bytes_per_second=\`$partitionWriteSpeedBytesPerSecond\`, -- Maximum allowed write speed per partition. + partition_write_burst_bytes=\`$partitionWriteBurstBytes\` -- Write quota allocated for write bursts. + -- When set to zero, the actual write_burst value is equalled to + -- the quota value (this allows write bursts of up to one second). + );`; +}; + +export const dropTopicTemplate = () => { + return `DROP TOPIC \`$path\`;`; +}; + +export const createViewTemplate = () => { + return `CREATE VIEW \`$path\` WITH (security_invoker=\`$securityInvoker\`) AS SELECT 1;`; +}; + +export const dropTableTemplate = () => { + return `DROP TABLE \`$path\`;`; +}; + +export const dropAsyncReplicationTemplate = () => { + return `DROP ASYNC REPLICATION \`$path\`;`; +}; + +export const alterAsyncReplicationTemplate = () => { + return `ALTER ASYNC REPLICATION \`$path\` SET (STATE=\`$state\`, FAILOVER_MODE=\`$failoverMode\`);`; +}; diff --git a/src/containers/Tenant/utils/schemaActions.ts b/src/containers/Tenant/utils/schemaActions.ts index 75db21f83..755595c7e 100644 --- a/src/containers/Tenant/utils/schemaActions.ts +++ b/src/containers/Tenant/utils/schemaActions.ts @@ -24,7 +24,7 @@ import { dropViewTemplate, selectQueryTemplate, upsertQueryTemplate, -} from './queryTemplates'; +} from './schemaQueryTemplates'; interface ActionsAdditionalEffects { updateQueryExecutionSettings: (settings?: Partial) => void; diff --git a/src/containers/Tenant/utils/queryTemplates.ts b/src/containers/Tenant/utils/schemaQueryTemplates.ts similarity index 100% rename from src/containers/Tenant/utils/queryTemplates.ts rename to src/containers/Tenant/utils/schemaQueryTemplates.ts