diff options
author | vityaman <[email protected]> | 2025-06-02 13:23:33 +0300 |
---|---|---|
committer | robot-piglet <[email protected]> | 2025-06-02 13:49:48 +0300 |
commit | f8dd75681a31f8b883f1c69db243a1ded8bb8d94 (patch) | |
tree | 4175cf2925fdc77e7f45bb9f84b65cc06a1a6829 /yql/essentials/sql/v1/complete/sql_complete_ut.cpp | |
parent | 70ff3797ac5c7fd31a1f092b4074dee5668fa0b1 (diff) |
YQL-19747: Complete named expressions
- Introduced scoped name collection at global analysis
- Added `BingingsNameService` constructed after global analysis and united with the base service.
- Added dollar detection at local analysis.
After this point design should be reexamined and module should be refactored.
---
- Related to `YQL-19747`
- Related to https://github.com/ydb-platform/ydb/issues/9056
- Related to https://github.com/vityaman/ydb/issues/57
---
Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1304
commit_hash:a7bf41703f0ee846e359407b53a5d62fc05928ea
Diffstat (limited to 'yql/essentials/sql/v1/complete/sql_complete_ut.cpp')
-rw-r--r-- | yql/essentials/sql/v1/complete/sql_complete_ut.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/yql/essentials/sql/v1/complete/sql_complete_ut.cpp b/yql/essentials/sql/v1/complete/sql_complete_ut.cpp index 7460924b48f..cc39fa875cc 100644 --- a/yql/essentials/sql/v1/complete/sql_complete_ut.cpp +++ b/yql/essentials/sql/v1/complete/sql_complete_ut.cpp @@ -39,6 +39,7 @@ public: }; Y_UNIT_TEST_SUITE(SqlCompleteTests) { + using ECandidateKind::BindingName; using ECandidateKind::ClusterName; using ECandidateKind::FolderName; using ECandidateKind::FunctionName; @@ -679,6 +680,7 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) { } { TVector<TCandidate> expected = { + {BindingName, "$hello"}, {TableName, "`maxim"}, {ClusterName, "example"}, {ClusterName, "saurus"}, @@ -694,6 +696,7 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) { } { TVector<TCandidate> expected = { + {BindingName, "$action"}, {TableName, "`people"}, {FolderName, "`yql/"}, {ClusterName, "example"}, @@ -983,6 +986,44 @@ Y_UNIT_TEST_SUITE(SqlCompleteTests) { UNIT_ASSERT_GE(Complete(engine, "SELECT 1;").size(), 35); } + Y_UNIT_TEST(Bindings) { + auto engine = MakeSqlCompletionEngineUT(); + + TString query = R"( + $=0; + $a=0; + $abac=0; + SELECT + )"; + + { + TVector<TCandidate> expected = { + {BindingName, "$a"}, + {BindingName, "$abac"}, + }; + UNIT_ASSERT_VALUES_EQUAL(CompleteTop(2, engine, query), expected); + } + { + TVector<TCandidate> expected = { + {BindingName, "$abac"}, + }; + UNIT_ASSERT_VALUES_EQUAL(CompleteTop(1, engine, query + "ab"), expected); + } + { + TVector<TCandidate> expected = { + {BindingName, "a"}, + {BindingName, "abac"}, + }; + UNIT_ASSERT_VALUES_EQUAL(Complete(engine, query + "$"), expected); + } + { + TVector<TCandidate> expected = { + {BindingName, "abac"}, + }; + UNIT_ASSERT_VALUES_EQUAL(Complete(engine, query + "$ab"), expected); + } + } + Y_UNIT_TEST(Typing) { const auto queryUtf16 = TUtf16String::FromUtf8( "SELECT \n" |