Skip to content

fix: query templates modification #1579

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

Merged
merged 5 commits into from
Nov 5, 2024
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: 1 addition & 1 deletion src/containers/Tenant/Query/NewSQL/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"action.create-topic": "Create Topic",
"action.drop-topic": "Drop Topic",
"action.alter-topic": "Alter Topic",
"action.create-cdc-stream": "Create CDC Stream",
"action.create-cdc-stream": "Create changefeed",
"action.create-async-replication": "Create async replication",
"action.create-user": "Create user",
"action.create-group": "Create group",
Expand Down
1 change: 1 addition & 0 deletions src/containers/Tenant/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"actions.dropView": "Drop view...",
"actions.alterTable": "Alter table...",
"actions.addTableIndex": "Add index...",
"actions.createCdcStream": "Create changefeed...",
"actions.alterTopic": "Alter topic...",
"actions.selectQuery": "Select query...",
"actions.upsertQuery": "Upsert query...",
Expand Down
6 changes: 6 additions & 0 deletions src/containers/Tenant/utils/schemaActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
alterTableTemplate,
alterTopicTemplate,
createAsyncReplicationTemplate,
createCdcStreamTemplate,
createColumnTableTemplate,
createExternalTableTemplate,
createTableTemplate,
Expand All @@ -28,6 +29,7 @@ import {
dropAsyncReplicationTemplate,
dropExternalTableTemplate,
dropTableIndex,
dropTableTemplate,
dropTopicTemplate,
dropViewTemplate,
selectQueryTemplate,
Expand Down Expand Up @@ -100,6 +102,7 @@ const bindActions = (
alterAsyncReplication: inputQuery(alterAsyncReplicationTemplate, 'script'),
dropAsyncReplication: inputQuery(dropAsyncReplicationTemplate, 'script'),
alterTable: inputQuery(alterTableTemplate, 'script'),
dropTable: inputQuery(dropTableTemplate, 'script'),
selectQuery: inputQuery(selectQueryTemplate),
upsertQuery: inputQuery(upsertQueryTemplate),
createExternalTable: inputQuery(createExternalTableTemplate, 'script'),
Expand All @@ -112,6 +115,7 @@ const bindActions = (
dropView: inputQuery(dropViewTemplate, 'script'),
dropIndex: inputQuery(dropTableIndex, 'script'),
addTableIndex: inputQuery(addTableIndex, 'script'),
createCdcStream: inputQuery(createCdcStreamTemplate, 'script'),
copyPath: () => {
try {
copy(params.relativePath);
Expand Down Expand Up @@ -166,9 +170,11 @@ export const getActions =
[copyItem],
[
{text: i18n('actions.alterTable'), action: actions.alterTable},
{text: i18n('actions.dropTable'), action: actions.dropTable},
{text: i18n('actions.selectQuery'), action: actions.selectQuery},
{text: i18n('actions.upsertQuery'), action: actions.upsertQuery},
{text: i18n('actions.addTableIndex'), action: actions.addTableIndex},
{text: i18n('actions.createCdcStream'), action: actions.createCdcStream},
],
];

Expand Down
6 changes: 5 additions & 1 deletion src/containers/Tenant/utils/schemaQueryTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ WITH (
);`;
};
export const alterTableTemplate = (params?: SchemaQueryParams) => {
return `ALTER TABLE \`${params?.relativePath || '$path'}\`
return `-- docs: https://ydb.tech/docs/en/yql/reference/syntax/alter_table/

ALTER TABLE \`${params?.relativePath || '$path'}\`
-- RENAME TO new_table_name
-- DROP COLUMN some_existing_column
ADD COLUMN numeric_column Int32;`;
};
export const selectQueryTemplate = (params?: SchemaQueryParams) => {
Expand Down
Loading