select_statement: add a warning about unsupported paging for vs queries
Currently we do not support paging for vector search queries.
When we get such a query with paging enabled we ignore the paging
and return the entire result. This behavior can be confusing for users,
as there is no warning about paging not working with vector search.
This patch fixes that by adding a warning to the result of ANN queries
with paging enabled.
Closes scylladb/scylladb#26384
(cherry picked from commit 7646dde25b)
Closes scylladb/scylladb#27016
This commit is contained in:
committed by
Botond Dénes
parent
034845e6eb
commit
c159ec4778
@@ -1184,6 +1184,11 @@ future<shared_ptr<cql_transport::messages::result_message>> indexed_table_select
|
||||
if (stats) {
|
||||
stats->add_latency(duration);
|
||||
}
|
||||
auto limit = get_limit(options, _limit);
|
||||
auto page_size = options.get_page_size();
|
||||
if (page_size > 0 && (uint64_t) page_size < limit) {
|
||||
result->add_warning("Paging is not supported for Vector Search queries. The entire result set has been returned.");
|
||||
}
|
||||
co_return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -953,3 +953,79 @@ SEASTAR_TEST_CASE(vector_search_metrics_test) {
|
||||
},
|
||||
cfg);
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(vector_store_client_test_paging_warning) {
|
||||
auto s1 = co_await make_vs_mock_server();
|
||||
|
||||
auto cfg = cql_test_config();
|
||||
cfg.db_config->vector_store_primary_uri.set(format("http://s1.node:{}", s1->port()));
|
||||
co_await do_with_cql_env(
|
||||
[&s1](cql_test_env& env) -> future<> {
|
||||
auto schema = co_await create_test_table(env, "ks", "test");
|
||||
auto& vs = env.local_qp().vector_store_client();
|
||||
configure(vs).with_dns({{"s1.node", std::vector<std::string>{s1->host()}}});
|
||||
|
||||
vs.start_background_tasks();
|
||||
auto result = co_await env.execute_cql("CREATE CUSTOM INDEX idx ON ks.test (embedding) USING 'vector_index'");
|
||||
auto qo = std::make_unique<cql3::query_options>(db::consistency_level::LOCAL_ONE, std::vector<cql3::raw_value>{},
|
||||
cql3::query_options::specific_options{5, nullptr, {}, api::new_timestamp()});
|
||||
auto msg = co_await env.execute_cql("SELECT * FROM ks.test ORDER BY embedding ANN OF [0.1, 0.2, 0.3] LIMIT 100;", std::move(qo));
|
||||
auto warns = msg->warnings();
|
||||
BOOST_REQUIRE_EQUAL(warns.size(), 1);
|
||||
BOOST_CHECK(warns[0] == "Paging is not supported for Vector Search queries. The entire result set has been returned.");
|
||||
},
|
||||
cfg)
|
||||
.finally([&s1] {
|
||||
return s1->stop();
|
||||
});
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(vector_store_client_test_paging_warning_doesnt_show_when_paging_disabled) {
|
||||
auto s1 = co_await make_vs_mock_server();
|
||||
|
||||
auto cfg = cql_test_config();
|
||||
cfg.db_config->vector_store_primary_uri.set(format("http://s1.node:{}", s1->port()));
|
||||
co_await do_with_cql_env(
|
||||
[&s1](cql_test_env& env) -> future<> {
|
||||
auto schema = co_await create_test_table(env, "ks", "test");
|
||||
auto& vs = env.local_qp().vector_store_client();
|
||||
configure(vs).with_dns({{"s1.node", std::vector<std::string>{s1->host()}}});
|
||||
|
||||
vs.start_background_tasks();
|
||||
auto result = co_await env.execute_cql("CREATE CUSTOM INDEX idx ON ks.test (embedding) USING 'vector_index'");
|
||||
auto qo = std::make_unique<cql3::query_options>(db::consistency_level::LOCAL_ONE, std::vector<cql3::raw_value>{},
|
||||
cql3::query_options::specific_options{0, nullptr, {}, api::new_timestamp()});
|
||||
auto msg = co_await env.execute_cql("SELECT * FROM ks.test ORDER BY embedding ANN OF [0.1, 0.2, 0.3] LIMIT 100;", std::move(qo));
|
||||
auto warns = msg->warnings();
|
||||
BOOST_REQUIRE_EQUAL(warns.size(), 0);
|
||||
},
|
||||
cfg)
|
||||
.finally([&s1] {
|
||||
return s1->stop();
|
||||
});
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(vector_store_client_test_paging_warning_doesnt_show_when_limit_less_than_page_size) {
|
||||
auto s1 = co_await make_vs_mock_server();
|
||||
|
||||
auto cfg = cql_test_config();
|
||||
cfg.db_config->vector_store_primary_uri.set(format("http://s1.node:{}", s1->port()));
|
||||
co_await do_with_cql_env(
|
||||
[&s1](cql_test_env& env) -> future<> {
|
||||
auto schema = co_await create_test_table(env, "ks", "test");
|
||||
auto& vs = env.local_qp().vector_store_client();
|
||||
configure(vs).with_dns({{"s1.node", std::vector<std::string>{s1->host()}}});
|
||||
|
||||
vs.start_background_tasks();
|
||||
auto result = co_await env.execute_cql("CREATE CUSTOM INDEX idx ON ks.test (embedding) USING 'vector_index'");
|
||||
auto qo = std::make_unique<cql3::query_options>(db::consistency_level::LOCAL_ONE, std::vector<cql3::raw_value>{},
|
||||
cql3::query_options::specific_options{100, nullptr, {}, api::new_timestamp()});
|
||||
auto msg = co_await env.execute_cql("SELECT * FROM ks.test ORDER BY embedding ANN OF [0.1, 0.2, 0.3] LIMIT 5;", std::move(qo));
|
||||
auto warns = msg->warnings();
|
||||
BOOST_REQUIRE_EQUAL(warns.size(), 0);
|
||||
},
|
||||
cfg)
|
||||
.finally([&s1] {
|
||||
return s1->stop();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user