diff options
author | vityaman <[email protected]> | 2025-04-28 17:50:31 +0300 |
---|---|---|
committer | robot-piglet <[email protected]> | 2025-04-28 18:13:27 +0300 |
commit | f35bf94dbc72f06a35459f8d854866b83b9a49ea (patch) | |
tree | b5afdcc946f4399860928e6a627fca041a69d91d /yql/essentials/sql/v1/complete/sql_complete_ut.cpp | |
parent | 3dfd8d9b20fe8902588dc35edb24423fbf165917 (diff) |
YQL-19747 Enable custom NameSet and FrequencyData
Clients might want to use custom `NameSet` and `FrequencyData` in their environment, for example, to get their private UDFs and to have more relevant ranking that includes their private UDF and respect their usage pattern.
To achieve this goal I decided to load pure `NameSet` and `FrequencyData` and provide functions for pruning. Also I checked defaults and decided that it is more common for a client to create a `StaticNameService` from pure `NameSet` and `FrequencyData` to keep their pruning consistent.
I also extracted a separate module `ranking`. It will be needed when I will implement `UnionNameService` to union `StaticNameService` and `SchemaNameService`. `UnionNameService` will load `Limit` names from each child and then crop them to sorted prefix of length `Limit` using `IRanking`.
---
- Related to `YQL-19747`
- Related to https://github.com/ydb-platform/ydb/issues/9056
- Related to https://github.com/vityaman/ydb/issues/14
---
Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1246
Co-authored-by: vvvv <[email protected]>
Co-authored-by: vvvv <[email protected]>
commit_hash:cdca301a58a34e56d537a447b4ff779cd70faea6
Diffstat (limited to 'yql/essentials/sql/v1/complete/sql_complete_ut.cpp')
-rw-r--r-- | yql/essentials/sql/v1/complete/sql_complete_ut.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/yql/essentials/sql/v1/complete/sql_complete_ut.cpp b/yql/essentials/sql/v1/complete/sql_complete_ut.cpp index b614f561492..54bcc35233f 100644 --- a/yql/essentials/sql/v1/complete/sql_complete_ut.cpp +++ b/yql/essentials/sql/v1/complete/sql_complete_ut.cpp @@ -1,8 +1,8 @@ #include "sql_complete.h" -#include <yql/essentials/sql/v1/complete/name/service/static/frequency.h> +#include <yql/essentials/sql/v1/complete/name/service/ranking/frequency.h> +#include <yql/essentials/sql/v1/complete/name/service/ranking/ranking.h> #include <yql/essentials/sql/v1/complete/name/service/static/name_service.h> -#include <yql/essentials/sql/v1/complete/name/service/static/ranking.h> #include <yql/essentials/sql/v1/lexer/lexer.h> #include <yql/essentials/sql/v1/lexer/antlr4_pure/lexer.h> @@ -49,7 +49,7 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) { ISqlCompletionEngine::TPtr MakeSqlCompletionEngineUT() { TLexerSupplier lexer = MakePureLexerSupplier(); - NameSet names = { + TNameSet names = { .Pragmas = {"yson.CastToString"}, .Types = {"Uint64"}, .Functions = {"StartsWith", "DateTime::Split"}, @@ -58,8 +58,8 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) { {EStatementKind::Insert, {"EXPIRATION"}}, }, }; - auto ranking = MakeDefaultRanking({}); - INameService::TPtr service = MakeStaticNameService(std::move(names), std::move(ranking)); + TFrequencyData frequency = {}; + INameService::TPtr service = MakeStaticNameService(std::move(names), std::move(frequency)); return MakeSqlCompletionEngine(std::move(lexer), std::move(service)); } @@ -669,8 +669,7 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) { } Y_UNIT_TEST(DefaultNameService) { - auto set = MakeDefaultNameSet(); - auto service = MakeStaticNameService(std::move(set), MakeDefaultRanking()); + auto service = MakeStaticNameService(LoadDefaultNameSet(), LoadFrequencyData()); auto engine = MakeSqlCompletionEngine(MakePureLexerSupplier(), std::move(service)); { TVector<TCandidate> expected = { @@ -711,10 +710,8 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) { } Y_UNIT_TEST(NameNormalization) { - auto set = MakeDefaultNameSet(); - auto service = MakeStaticNameService(std::move(set), MakeDefaultRanking()); + auto service = MakeStaticNameService(LoadDefaultNameSet(), LoadFrequencyData()); auto engine = MakeSqlCompletionEngine(MakePureLexerSupplier(), std::move(service)); - TVector<TCandidate> expected = { {HintName, "IGNORE_TYPE_V3"}, }; @@ -749,7 +746,9 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) { {"unordered", 2}, }, }; - auto service = MakeStaticNameService(MakeDefaultNameSet(), MakeDefaultRanking(frequency)); + auto service = MakeStaticNameService( + Pruned(LoadDefaultNameSet(), LoadFrequencyData()), + std::move(frequency)); auto engine = MakeSqlCompletionEngine(MakePureLexerSupplier(), std::move(service)); { TVector<TCandidate> expected = { |