From 2feed49285daf48be94448d2e51e4056e7355cd8 Mon Sep 17 00:00:00 2001 From: Dawid Pawlik Date: Wed, 11 Feb 2026 13:39:02 +0100 Subject: [PATCH] test/vector_search: add reproducer for rescoring with zero vectors Add reproducer for the SCYLLADB-456 issue following exception on ANN vector queries with rescoring with similarity cosine. (cherry picked from commit 4e32502bb3a7ab87a4bb94a121427f3d2b4c7e1d) --- test/vector_search/rescoring_test.cc | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/vector_search/rescoring_test.cc b/test/vector_search/rescoring_test.cc index 368fd91b20..bc0d3c9167 100644 --- a/test/vector_search/rescoring_test.cc +++ b/test/vector_search/rescoring_test.cc @@ -460,3 +460,38 @@ SEASTAR_TEST_CASE(no_nulls_in_rescored_results, *boost::unit_test::expected_fail })); } } + +// Reproducer for SCYLLADB-456 +SEASTAR_TEST_CASE(rescoring_with_zerovector_query) { + for (const auto& params : test_data) { + auto server = co_await make_vs_mock_server(); + co_await do_with_cql_env( + [&](cql_test_env& env) -> future<> { + configure(env.local_qp().vector_store_client()).with_dns({{"server.node", std::vector{server->host()}}}); + env.local_qp().vector_store_client().start_background_tasks(); + + co_await create_index_and_insert_data(env, params); + + server->next_ann_response({http::reply::status_type::ok, R"({ + "primary_keys": { "id": [4, 3, 2, 1] }, + "distances": [0, 0, 0, 0] + })"}); + + // For cosine similarity the ANN vector query would fail as `similarity_cosine` function did not support zero vectors. + try { + auto msg = co_await env.execute_cql("SELECT id FROM ks.cf ORDER BY embedding ANN OF [0, 0] LIMIT 3;"); + + auto rms = dynamic_pointer_cast(msg); + BOOST_REQUIRE(rms); + const auto& rows = rms->rs().result_set().rows(); + BOOST_REQUIRE_EQUAL(rows.size(), 3); + } catch (const std::exception& e) { + BOOST_FAIL(e.what()); + } + }, + make_config(format("http://server.node:{}", server->port()))) + .finally(seastar::coroutine::lambda([&] -> future<> { + co_await server->stop(); + })); + } +}