diff --git a/test/cqlpy/test_vector_search_with_vector_store_mock.py b/test/cqlpy/test_vector_search_with_vector_store_mock.py index 880f08cf81..ec85e744c0 100644 --- a/test/cqlpy/test_vector_search_with_vector_store_mock.py +++ b/test/cqlpy/test_vector_search_with_vector_store_mock.py @@ -166,3 +166,21 @@ def test_vector_search_cql_error_contains_http_error_description(cql, test_keysp with pytest.raises(InvalidRequest, match="404.*index does not exist"): cql.execute( f"SELECT * FROM {table} ORDER BY embedding ANN OF [0.1, 0.2, 0.3] LIMIT 5") + + +# Create a vector index with an additional filtering column. +# Because the local secondary index logic was used to determine the index target column, +# the implementation wrongly selects last column as the target(vectors) column, leading to +# an exception on the SELECT query: +# ANN ordering by vector requires the column to be indexed using 'vector_index'. +# Reproduces SCYLLADB-635. +def test_vector_search_vector_index_with_additional_filtering_column(cql, test_keyspace, vector_store_mock, skip_without_tablets): + + schema = "pk1 tinyint, pk2 tinyint, ck1 tinyint, ck2 tinyint, embedding vector, PRIMARY KEY ((pk1, pk2), ck1, ck2)" + + with new_test_table(cql, test_keyspace, schema) as table: + cql.execute( + f"CREATE CUSTOM INDEX ON {table}(embedding, ck1) USING 'vector_index'") + + cql.execute( + f"SELECT * FROM {table} ORDER BY embedding ANN OF [0.1, 0.2, 0.3] LIMIT 5") diff --git a/test/vector_search/vector_store_client_test.cc b/test/vector_search/vector_store_client_test.cc index 2ba97fb743..6e7fd6f5e0 100644 --- a/test/vector_search/vector_store_client_test.cc +++ b/test/vector_search/vector_store_client_test.cc @@ -1206,21 +1206,6 @@ SEASTAR_TEST_CASE(vector_store_client_abort_due_to_query_timeout) { })); } -// Create a vector index with an additional filtering column. -// Because the local secondary index logic was used to determine the index target column, -// the implementation wrongly selects last column as the target(vectors) column, leading to an exception -// on the SELECT query: -// ANN ordering by vector requires the column to be indexed using 'vector_index'. -// Reproduces SCYLLADB-635. -SEASTAR_TEST_CASE(vector_store_client_vector_index_with_additional_filtering_column) { - co_await do_with_vector_store_mock([](cql_test_env& env, vs_mock_server&) -> future<> { - // Create a vector index on the embedding column, including ck1 for filtered ANN search support. - co_await env.execute_cql("CREATE CUSTOM INDEX idx ON ks.test (embedding, ck1) USING 'vector_index'"); - - BOOST_CHECK_NO_THROW(co_await env.execute_cql("SELECT * FROM ks.test ORDER BY embedding ANN OF [0.1, 0.2, 0.3] LIMIT 5;")); - }); -} - SEASTAR_TEST_CASE(vector_store_client_local_vector_index) { co_await do_with_vector_store_mock([](cql_test_env& env, vs_mock_server&) -> future<> { // Create a local vector index on the 'embedding' column.