Skip to content
Open
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
4 changes: 4 additions & 0 deletions src/containers/Tenant/Query/NewSQL/NewSQL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export function NewSQL() {
text: i18n('action.add-index'),
action: actions.addTableIndex,
},
{
text: i18n('action.add-vector-index'),
action: actions.addVectorIndex,
},
{
text: i18n('action.drop-index'),
action: actions.dropTableIndex,
Expand Down
1 change: 1 addition & 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,7 @@
"action.delete-rows": "Delete rows",
"action.drop-table": "Drop table",
"action.add-index": "Add index",
"action.add-vector-index": "Add vector index",
"action.drop-index": "Drop index",
"action.drop-external-table": "Drop external table",
"menu.tables": "Tables",
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 @@ -44,6 +44,7 @@
"actions.manageColumns": "Manage columns...",
"actions.manageAutoPartitioning": "Manage auto partitioning...",
"actions.addTableIndex": "Add index...",
"actions.addVectorIndex": "Add vector index...",
"actions.createCdcStream": "Create changefeed...",
"actions.showCreateTable": "Show Create SQL...",
"actions.alterTopic": "Alter topic...",
Expand Down
2 changes: 2 additions & 0 deletions src/containers/Tenant/utils/newSQLQueryActions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
addTableIndex,
addVectorIndex,
alterAsyncReplicationTemplate,
alterStreamingQuerySettingsTemplate,
alterStreamingQueryText,
Expand Down Expand Up @@ -72,6 +73,7 @@ export const bindActions = (changeUserInput: (input: string) => void) => {
revokePrivilege: inputQuery(revokePrivilegeTemplate),
dropUser: inputQuery(dropUserTemplate),
dropGroup: inputQuery(dropGroupTemplate),
addVectorIndex: inputQuery(addVectorIndex),
addTableIndex: inputQuery(addTableIndex),
dropTableIndex: inputQuery(dropTableIndex),
showCreateTable: inputQuery(showCreateTableTemplate),
Expand Down
3 changes: 3 additions & 0 deletions src/containers/Tenant/utils/schemaActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import i18n from '../i18n';
import type {TemplateFn} from './schemaQueryTemplates';
import {
addTableIndex,
addVectorIndex,
alterAsyncReplicationTemplate,
alterStreamingQuerySettingsTemplate,
alterStreamingQueryText,
Expand Down Expand Up @@ -152,6 +153,7 @@ const bindActions = (
alterStreamingQueryText: inputQuery(alterStreamingQueryText),
dropStreamingQuery: inputQuery(dropStreamingQueryTemplate),
dropIndex: inputQuery(dropTableIndex),
addVectorIndex: inputQuery(addVectorIndex),
addTableIndex: inputQuery(addTableIndex),
createCdcStream: inputQuery(createCdcStreamTemplate),
copyPath: () => {
Expand Down Expand Up @@ -299,6 +301,7 @@ export const getActions =
isLoading: additionalEffects.isSchemaDataLoading,
}),
{text: i18n('actions.addTableIndex'), action: actions.addTableIndex},
{text: i18n('actions.addVectorIndex'), action: actions.addVectorIndex},
{text: i18n('actions.createCdcStream'), action: actions.createCdcStream},
],
[showCreateTableItem],
Expand Down
19 changes: 19 additions & 0 deletions src/containers/Tenant/utils/schemaQueryTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,25 @@ export const addTableIndex = (params?: SchemaQueryParams) => {
return `ALTER TABLE ${path} ADD INDEX \${2:index_name} GLOBAL ON (\${3:<column_name>});`;
};

export const addVectorIndex = (params?: SchemaQueryParams) => {
const path = params?.relativePath
? `\`${normalizeParameter(params.relativePath)}\``
: '${1:<my_table>}';

return `-- docs: https://ydb.tech/docs/en/dev/vector-indexes?version=main#types
ALTER TABLE ${path}
ADD INDEX \${2:my_vector_index}
GLOBAL USING vector_kmeans_tree
ON (\${3:embedding})
WITH (
distance=cosine,
vector_type="uint8",
vector_dimension=\${4:512},
levels=\${5:2},
clusters=\${6:128}
);`;
};

export const dropTableIndex = (params?: SchemaQueryParams) => {
const indexName = params?.relativePath.split('/').pop();
const path = params?.relativePath.split('/').slice(0, -1).join('/');
Expand Down
Loading