diff options
author | azevaykin <145343289+azevaykin@users.noreply.github.com> | 2025-04-18 12:38:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-18 12:38:06 +0300 |
commit | 3745d96291a79d19a9abfa0166cd46ba751eb52f (patch) | |
tree | 5f8fa601c7ab71eb0bea5382d7dc81c4a7a3c3a5 | |
parent | 0fbe2c41987bb2a4c9960332eae51ea3b8cbb9c9 (diff) | |
download | ydb-3745d96291a79d19a9abfa0166cd46ba751eb52f.tar.gz |
Table with vector index is updatable but vector index is unchanged (#17358)
-rw-r--r-- | ydb/core/kqp/provider/yql_kikimr_gateway.h | 2 | ||||
-rw-r--r-- | ydb/core/kqp/ut/indexes/kqp_indexes_ut.cpp | 71 |
2 files changed, 72 insertions, 1 deletions
diff --git a/ydb/core/kqp/provider/yql_kikimr_gateway.h b/ydb/core/kqp/provider/yql_kikimr_gateway.h index 318b21c713a..30718416ecb 100644 --- a/ydb/core/kqp/provider/yql_kikimr_gateway.h +++ b/ydb/core/kqp/provider/yql_kikimr_gateway.h @@ -203,7 +203,7 @@ struct TIndexDescription { case EType::GlobalAsync: return false; case EType::GlobalSyncVectorKMeansTree: - return true; + return false; } } diff --git a/ydb/core/kqp/ut/indexes/kqp_indexes_ut.cpp b/ydb/core/kqp/ut/indexes/kqp_indexes_ut.cpp index 0cf0badfe43..a05490508b0 100644 --- a/ydb/core/kqp/ut/indexes/kqp_indexes_ut.cpp +++ b/ydb/core/kqp/ut/indexes/kqp_indexes_ut.cpp @@ -3238,6 +3238,77 @@ Y_UNIT_TEST_SUITE(KqpIndexes) { DoPositiveQueriesPrefixedVectorIndexOrderByCosine(session); } + Y_UNIT_TEST(VectorIndexIsNotUpdatable) { + NKikimrConfig::TFeatureFlags featureFlags; + featureFlags.SetEnableVectorIndex(true); + auto setting = NKikimrKqp::TKqpSetting(); + auto serverSettings = TKikimrSettings() + .SetFeatureFlags(featureFlags) + .SetKqpSettings({setting}); + + TKikimrRunner kikimr(serverSettings); + kikimr.GetTestServer().GetRuntime()->SetLogPriority(NKikimrServices::BUILD_INDEX, NActors::NLog::PRI_TRACE); + + auto db = kikimr.GetTableClient(); + auto session = DoCreateTableForVectorIndex(db, true); + + // Add first index + { + const TString createIndex(Q_(R"( + ALTER TABLE `/Root/TestTable` + ADD INDEX index1 + GLOBAL USING vector_kmeans_tree + ON (emb) + WITH (similarity=cosine, vector_type="uint8", vector_dimension=2, levels=2, clusters=2); + )")); + + auto result = session.ExecuteSchemeQuery(createIndex).ExtractValueSync(); + + UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString()); + } + + const TString originalPostingTable = ReadTablePartToYson(session, "/Root/TestTable/index1/indexImplPostingTable"); + + // Upsert to the table with index should succeed + { + const TString query1(Q_(R"( + UPSERT INTO `/Root/TestTable` (pk, emb, data) VALUES)" + "(10, \"\x76\x76\x03\", \"10\");" + )); + + auto result = session.ExecuteDataQuery( + query1, + TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()) + .ExtractValueSync(); + UNIT_ASSERT(result.IsSuccess()); + } + + const TString postingTable1 = ReadTablePartToYson(session, "/Root/TestTable/index1/indexImplPostingTable"); + + // First index is not updated + UNIT_ASSERT_STRINGS_EQUAL(originalPostingTable, postingTable1); + + // Add second index + { + const TString createIndex(Q_(R"( + ALTER TABLE `/Root/TestTable` + ADD INDEX index2 + GLOBAL USING vector_kmeans_tree + ON (emb) + WITH (similarity=cosine, vector_type="uint8", vector_dimension=2, levels=2, clusters=2); + )")); + + auto result = session.ExecuteSchemeQuery(createIndex).ExtractValueSync(); + + UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString()); + } + + const TString postingTable2 = ReadTablePartToYson(session, "/Root/TestTable/index2/indexImplPostingTable"); + + // Second index is different + UNIT_ASSERT_STRINGS_UNEQUAL(originalPostingTable, postingTable2); + } + Y_UNIT_TEST(ExplainCollectFullDiagnostics) { auto setting = NKikimrKqp::TKqpSetting(); auto serverSettings = TKikimrSettings() |