summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/complete/sql_complete.cpp
diff options
context:
space:
mode:
authorvityaman <[email protected]>2025-06-02 13:23:33 +0300
committerrobot-piglet <[email protected]>2025-06-02 13:49:48 +0300
commitf8dd75681a31f8b883f1c69db243a1ded8bb8d94 (patch)
tree4175cf2925fdc77e7f45bb9f84b65cc06a1a6829 /yql/essentials/sql/v1/complete/sql_complete.cpp
parent70ff3797ac5c7fd31a1f092b4074dee5668fa0b1 (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.cpp')
-rw-r--r--yql/essentials/sql/v1/complete/sql_complete.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/yql/essentials/sql/v1/complete/sql_complete.cpp b/yql/essentials/sql/v1/complete/sql_complete.cpp
index 807786512e4..eb7610640a1 100644
--- a/yql/essentials/sql/v1/complete/sql_complete.cpp
+++ b/yql/essentials/sql/v1/complete/sql_complete.cpp
@@ -2,7 +2,10 @@
#include <yql/essentials/sql/v1/complete/syntax/grammar.h>
#include <yql/essentials/sql/v1/complete/text/word.h>
+#include <yql/essentials/sql/v1/complete/name/service/ranking/dummy.h>
+#include <yql/essentials/sql/v1/complete/name/service/binding/name_service.h>
#include <yql/essentials/sql/v1/complete/name/service/static/name_service.h>
+#include <yql/essentials/sql/v1/complete/name/service/union/name_service.h>
#include <yql/essentials/sql/v1/complete/syntax/local.h>
#include <yql/essentials/sql/v1/complete/syntax/format.h>
#include <yql/essentials/sql/v1/complete/analysis/global/global.h>
@@ -52,7 +55,14 @@ namespace NSQLComplete {
});
}
- return Names_->Lookup(std::move(request))
+ TVector<INameService::TPtr> children;
+ children.emplace_back(MakeBindingNameService(std::move(global.Names)));
+ if (!context.Binding) {
+ children.emplace_back(Names_);
+ }
+
+ return MakeUnionNameService(std::move(children), MakeDummyRanking())
+ ->Lookup(std::move(request))
.Apply([this, input, context = std::move(context)](auto f) {
return ToCompletion(input, context, f.ExtractValue());
});
@@ -202,6 +212,13 @@ namespace NSQLComplete {
return {ECandidateKind::ClusterName, std::move(name.Indentifier)};
}
+ if constexpr (std::is_base_of_v<TBindingName, T>) {
+ if (!context.Binding) {
+ name.Indentifier.prepend('$');
+ }
+ return {ECandidateKind::BindingName, std::move(name.Indentifier)};
+ }
+
if constexpr (std::is_base_of_v<TUnkownName, T>) {
return {ECandidateKind::UnknownName, std::move(name.Content)};
}
@@ -290,6 +307,9 @@ void Out<NSQLComplete::ECandidateKind>(IOutputStream& out, NSQLComplete::ECandid
case NSQLComplete::ECandidateKind::ClusterName:
out << "ClusterName";
break;
+ case NSQLComplete::ECandidateKind::BindingName:
+ out << "BindingName";
+ break;
case NSQLComplete::ECandidateKind::UnknownName:
out << "UnknownName";
break;