Skip to content

Commit a473e5e

Browse files
committed
validator/common: extend create_index function with options
Since the change we may create the indexes with different than default vector index parameters like e.g. 'similarity_function'.
1 parent fb54a70 commit a473e5e

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

crates/validator/src/common.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,20 @@ pub(crate) async fn create_index(
151151
client: &HttpClient,
152152
table: &str,
153153
column: &str,
154+
options: Option<&str>,
154155
) -> IndexInfo {
155156
let index = format!("idx_{}", Uuid::new_v4().simple());
156157

158+
let extra = if let Some(options) = options {
159+
format!("WITH OPTIONS = {options}")
160+
} else {
161+
String::new()
162+
};
163+
157164
// Create index
158165
session
159166
.query_unpaged(
160-
format!("CREATE INDEX {index} ON {table}({column}) USING 'vector_index'"),
167+
format!("CREATE INDEX {index} ON {table}({column}) USING 'vector_index' {extra}"),
161168
(),
162169
)
163170
.await

crates/validator/src/tests/ann.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async fn ann_query_returns_expected_results(actors: TestActors) {
6161
.expect("failed to insert data");
6262
}
6363

64-
let index = create_index(&session, &client, &table, "v").await;
64+
let index = create_index(&session, &client, &table, "v", None).await;
6565

6666
wait_for(
6767
|| async { client.count(&index.keyspace, &index.index).await == Some(1000) },
@@ -121,7 +121,7 @@ async fn ann_query_respects_limit(actors: TestActors) {
121121
}
122122

123123
// Create index
124-
let index = create_index(&session, &client, &table, "v").await;
124+
let index = create_index(&session, &client, &table, "v", None).await;
125125

126126
wait_for(
127127
|| async { client.count(&index.keyspace, &index.index).await == Some(10) },
@@ -189,7 +189,7 @@ async fn ann_query_respects_limit_over_1000_vectors(actors: TestActors) {
189189
.expect("failed to insert data");
190190
}
191191

192-
let index = create_index(&session, &client, &table, "v").await;
192+
let index = create_index(&session, &client, &table, "v", None).await;
193193

194194
wait_for(
195195
|| async { client.count(&index.keyspace, &index.index).await == Some(1111) },

crates/validator/src/tests/crud.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async fn simple_create_drop_index(actors: TestActors) {
3838
)
3939
.await;
4040

41-
let index = create_index(&session, &client, &table, "embedding").await;
41+
let index = create_index(&session, &client, &table, "embedding", None).await;
4242

4343
assert_eq!(index.keyspace.as_ref(), &keyspace);
4444

@@ -71,7 +71,7 @@ async fn simple_create_drop_multiple_indexes(actors: TestActors) {
7171
.await;
7272

7373
// Create index on column v1
74-
let index1 = create_index(&session, &client, &table, "v1").await;
74+
let index1 = create_index(&session, &client, &table, "v1", None).await;
7575

7676
// Wait for the full scan to complete and check if ANN query succeeds on v1
7777
wait_for(
@@ -99,7 +99,7 @@ async fn simple_create_drop_multiple_indexes(actors: TestActors) {
9999
.expect_err("ANN query should fail when index does not exist");
100100

101101
// Create index on column v2
102-
let index2 = create_index(&session, &client, &table, "v2").await;
102+
let index2 = create_index(&session, &client, &table, "v2", None).await;
103103

104104
// Check if ANN query on v1 still succeeds
105105
session

crates/validator/src/tests/full_scan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async fn full_scan_is_completed_when_responding_to_messages_concurrently(actors:
4444
.expect("failed to insert data");
4545
}
4646

47-
let index = create_index(&session, &client, &table, "embedding").await;
47+
let index = create_index(&session, &client, &table, "embedding", None).await;
4848

4949
let result = session
5050
.query_unpaged(

crates/validator/src/tests/reconnect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async fn reconnect_doesnt_break_fullscan(actors: TestActors) {
4949
.expect("failed to insert a row");
5050
}
5151

52-
let index = create_index(&session, &client, &table, "embedding").await;
52+
let index = create_index(&session, &client, &table, "embedding", None).await;
5353

5454
let result = session
5555
.query_unpaged(

0 commit comments

Comments
 (0)