-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support create a default vector index
- Loading branch information
Libao Yang
authored and
Shanfeng Pang
committed
Apr 30, 2024
1 parent
06087e4
commit 72ddda3
Showing
7 changed files
with
135 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/queries/2_vector_search/00041_mqvs_support_create_default_index.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Create default vector indices when creating table | ||
vec_ind_1 MSTG vec_ind_1 vector_1 TYPE DEFAULT | ||
vec_ind_2 MSTG vec_ind_2 vector_2 TYPE default(\'metric_type=IP\') | ||
vec_ind_7 BinaryMSTG vec_ind_7 vector_7 TYPE DEFAULT | ||
vec_ind_8 BinaryMSTG vec_ind_8 vector_8 TYPE default(\'metric_type=Jaccard\') | ||
Create default vector indices in ALTER TABLE ADD VECTOR INDEX query | ||
vec_ind_1 MSTG vec_ind_1 vector_1 TYPE DEFAULT | ||
vec_ind_2 MSTG vec_ind_2 vector_2 TYPE default(\'metric_type=IP\') | ||
vec_ind_7 BinaryMSTG vec_ind_7 vector_7 TYPE DEFAULT | ||
vec_ind_8 BinaryMSTG vec_ind_8 vector_8 TYPE default(\'metric_type=Jaccard\') | ||
vec_ind_3 MSTG vec_ind_3 vector_3 TYPE DEFAULT | ||
vec_ind_4 MSTG vec_ind_4 vector_4 TYPE default | ||
vec_ind_9 BinaryMSTG vec_ind_9 vector_9 TYPE DEFAULT | ||
vec_ind_10 BinaryMSTG vec_ind_10 vector_10 TYPE default | ||
Create default vector indices in CREATE VECTOR INDEX query | ||
vec_ind_1 MSTG vec_ind_1 vector_1 TYPE DEFAULT | ||
vec_ind_2 MSTG vec_ind_2 vector_2 TYPE default(\'metric_type=IP\') | ||
vec_ind_7 BinaryMSTG vec_ind_7 vector_7 TYPE DEFAULT | ||
vec_ind_8 BinaryMSTG vec_ind_8 vector_8 TYPE default(\'metric_type=Jaccard\') | ||
vec_ind_3 MSTG vec_ind_3 vector_3 TYPE DEFAULT | ||
vec_ind_4 MSTG vec_ind_4 vector_4 TYPE default | ||
vec_ind_9 BinaryMSTG vec_ind_9 vector_9 TYPE DEFAULT | ||
vec_ind_10 BinaryMSTG vec_ind_10 vector_10 TYPE default | ||
vec_ind_5 MSTG vec_ind_5 vector_5 TYPE DEFAULT | ||
vec_ind_6 MSTG vec_ind_6 vector_6 TYPE default | ||
vec_ind_11 BinaryMSTG vec_ind_11 vector_11 TYPE DEFAULT | ||
vec_ind_12 BinaryMSTG vec_ind_12 vector_12 TYPE default |
72 changes: 72 additions & 0 deletions
72
tests/queries/2_vector_search/00041_mqvs_support_create_default_index.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
-- Tags: no-parallel | ||
|
||
DROP TABLE IF EXISTS t_create_default_index; | ||
|
||
-- create table and create default vector indices | ||
CREATE TABLE t_create_default_index( | ||
id UInt64, | ||
vector_1 Array(Float32), | ||
vector_2 Array(Float32), | ||
vector_3 Array(Float32), | ||
vector_4 Array(Float32), | ||
vector_5 Array(Float32), | ||
vector_6 Array(Float32), | ||
vector_7 FixedString(3), | ||
vector_8 FixedString(3), | ||
vector_9 FixedString(3), | ||
vector_10 FixedString(3), | ||
vector_11 FixedString(3), | ||
vector_12 FixedString(3), | ||
CONSTRAINT vector_len_1 CHECK length(vector_1) = 3, | ||
CONSTRAINT vector_len_2 CHECK length(vector_2) = 3, | ||
CONSTRAINT vector_len_3 CHECK length(vector_3) = 3, | ||
CONSTRAINT vector_len_4 CHECK length(vector_4) = 3, | ||
CONSTRAINT vector_len_5 CHECK length(vector_5) = 3, | ||
CONSTRAINT vector_len_6 CHECK length(vector_6) = 3, | ||
VECTOR INDEX vec_ind_1 vector_1, | ||
VECTOR INDEX vec_ind_2 vector_2 TYPE default('metric_type=IP'), | ||
VECTOR INDEX vec_ind_7 vector_7, | ||
VECTOR INDEX vec_ind_8 vector_8 TYPE default('metric_type=Jaccard'), | ||
) ENGINE = MergeTree ORDER BY id; | ||
|
||
INSERT INTO t_create_default_index SELECT | ||
number, | ||
[number, number, number], | ||
[number, number, number], | ||
[number, number, number], | ||
[number, number, number], | ||
[number, number, number], | ||
[number, number, number], | ||
char(number, number, number), | ||
char(number, number, number), | ||
char(number, number, number), | ||
char(number, number, number), | ||
char(number, number, number), | ||
char(number, number, number) | ||
FROM numbers(10); | ||
|
||
SELECT 'Create default vector indices when creating table'; | ||
SELECT name, type, expr FROM system.vector_indices WHERE table = 't_create_default_index'; | ||
|
||
|
||
-- alter table to add default vector indices | ||
ALTER TABLE t_create_default_index ADD VECTOR INDEX vec_ind_3 vector_3; | ||
ALTER TABLE t_create_default_index ADD VECTOR INDEX vec_ind_4 vector_4 TYPE default; | ||
|
||
ALTER TABLE t_create_default_index ADD VECTOR INDEX vec_ind_9 vector_9; | ||
ALTER TABLE t_create_default_index ADD VECTOR INDEX vec_ind_10 vector_10 TYPE default; | ||
|
||
SELECT 'Create default vector indices in ALTER TABLE ADD VECTOR INDEX query'; | ||
SELECT name, type, expr FROM system.vector_indices WHERE table = 't_create_default_index'; | ||
|
||
-- create default vector indices | ||
CREATE VECTOR INDEX vec_ind_5 ON t_create_default_index vector_5; | ||
CREATE VECTOR INDEX vec_ind_6 ON t_create_default_index vector_6 TYPE default; | ||
|
||
CREATE VECTOR INDEX vec_ind_11 ON t_create_default_index vector_11; | ||
CREATE VECTOR INDEX vec_ind_12 ON t_create_default_index vector_12 TYPE default; | ||
|
||
SELECT 'Create default vector indices in CREATE VECTOR INDEX query'; | ||
SELECT name, type, expr FROM system.vector_indices WHERE table = 't_create_default_index'; | ||
|
||
DROP TABLE IF EXISTS t_create_default_index; |