Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions src/containers/Tenant/Query/NewSQL/NewSQL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ export function NewSQL() {
text: i18n('action.drop-external-table'),
action: actions.dropExternalTable,
},
{
text: i18n('action.add-index'),
action: actions.addTableIndex,
},
{
text: i18n('action.drop-index'),
action: actions.dropTableIndex,
},
],
},
{
Expand Down
2 changes: 2 additions & 0 deletions src/containers/Tenant/Query/NewSQL/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"action.select-from-external-table": "Select from external table",
"action.delete-rows": "Delete rows",
"action.drop-table": "Drop table",
"action.add-index": "Add index",
"action.drop-index": "Drop index",
"action.drop-external-table": "Drop external table",
"menu.tables": "Tables",
"menu.topics": "Topics",
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 @@ -36,6 +36,7 @@
"actions.dropTopic": "Drop topic...",
"actions.dropView": "Drop view...",
"actions.alterTable": "Alter table...",
"actions.addTableIndex": "Add index...",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want to add action "Drop index..." directly to index entity?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added INDEX_SET

"actions.alterTopic": "Alter topic...",
"actions.selectQuery": "Select query...",
"actions.upsertQuery": "Upsert query...",
Expand Down
4 changes: 4 additions & 0 deletions src/containers/Tenant/utils/newSQLQueryActions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {changeUserInput} from '../../../store/reducers/executeQuery';

import {
addTableIndex,
alterAsyncReplicationTemplate,
alterTableTemplate,
alterTopicTemplate,
Expand All @@ -17,6 +18,7 @@ import {
dropAsyncReplicationTemplate,
dropExternalTableTemplate,
dropGroupTemplate,
dropTableIndex,
dropTableTemplate,
dropTopicTemplate,
dropUserTemplate,
Expand Down Expand Up @@ -58,5 +60,7 @@ export const bindActions = (dispatch: React.Dispatch<any>) => {
revokePrivilege: inputQuery(revokePrivilegeTemplate),
dropUser: inputQuery(dropUserTemplate),
dropGroup: inputQuery(dropGroupTemplate),
addTableIndex: inputQuery(addTableIndex),
dropTableIndex: inputQuery(dropTableIndex),
};
};
8 changes: 8 additions & 0 deletions src/containers/Tenant/utils/newSQLQueryTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,11 @@ export const dropAsyncReplicationTemplate = () => {
export const alterAsyncReplicationTemplate = () => {
return `ALTER ASYNC REPLICATION \`$path\` SET (STATE=\`$state\`, FAILOVER_MODE=\`$failoverMode\`);`;
};

export const addTableIndex = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may use function addTableIndex('$path') from src/containers/Tenant/utils/schemaQueryTemplates.ts . In most cases templates are identical.
What do you think if we create general template creators and use them if possible? This will prevent double-fixing templates.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on a second thougth this can be done right here

return `ALTER TABLE \`$path\` ADD INDEX \`$indexName\` GLOBAL ON (\`$columnName\`);`;
};

export const dropTableIndex = () => {
return `ALTER TABLE \`$path\` DROP INDEX \`$indexName\`;`;
};
3 changes: 3 additions & 0 deletions src/containers/Tenant/utils/schemaActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {transformPath} from '../ObjectSummary/transformPath';
import i18n from '../i18n';

import {
addTableIndex,
alterAsyncReplicationTemplate,
alterTableTemplate,
alterTopicTemplate,
Expand Down Expand Up @@ -74,6 +75,7 @@ const bindActions = (
dropTopic: inputQuery(dropTopicTemplate, 'script'),
createView: inputQuery(createViewTemplate, 'script'),
dropView: inputQuery(dropViewTemplate, 'script'),
addTableIndex: inputQuery(addTableIndex, 'script'),
copyPath: () => {
try {
copy(relativePath);
Expand Down Expand Up @@ -126,6 +128,7 @@ export const getActions =
{text: i18n('actions.alterTable'), action: actions.alterTable},
{text: i18n('actions.selectQuery'), action: actions.selectQuery},
{text: i18n('actions.upsertQuery'), action: actions.upsertQuery},
{text: i18n('actions.addTableIndex'), action: actions.addTableIndex},
],
];

Expand Down
4 changes: 4 additions & 0 deletions src/containers/Tenant/utils/schemaQueryTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,7 @@ export const dropAsyncReplicationTemplate = (path: string) => {
export const alterAsyncReplicationTemplate = (path: string) => {
return `ALTER ASYNC REPLICATION \`${path}\` SET (STATE = "DONE", FAILOVER_MODE = "FORCE");`;
};

export const addTableIndex = (path: string) => {
return `ALTER TABLE \`${path}\` ADD INDEX \`$indexName\` GLOBAL ON (\`$columnName\`);`;
};
Loading