diff options
author | vitya-smirnov <[email protected]> | 2025-07-10 16:18:41 +0300 |
---|---|---|
committer | vitya-smirnov <[email protected]> | 2025-07-10 16:49:06 +0300 |
commit | ab4a6f4beadc1b478f8c208d07226687821b5fc2 (patch) | |
tree | e19e74f48361d1aa73d139c23ae514ea8ab4453f /yql/essentials/sql/v1/complete/sql_complete.cpp | |
parent | ea2073d5c0897338da46444473d7649ceac2289b (diff) |
YQL-19747: Complete table functions
- Added table functions completion.
- Also fixed a bug when USEd cluster
was not added to table context at table
function argument.
- Complete folder names at `prefix`
of `LIKE`, `RANGE`, etc.
commit_hash:26be383be728796e8431f906e2815acd77645ad4
Diffstat (limited to 'yql/essentials/sql/v1/complete/sql_complete.cpp')
-rw-r--r-- | yql/essentials/sql/v1/complete/sql_complete.cpp | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/yql/essentials/sql/v1/complete/sql_complete.cpp b/yql/essentials/sql/v1/complete/sql_complete.cpp index cf93c07a190..253e4731835 100644 --- a/yql/essentials/sql/v1/complete/sql_complete.cpp +++ b/yql/essentials/sql/v1/complete/sql_complete.cpp @@ -65,6 +65,8 @@ namespace NSQLComplete { TGlobalContext global = GlobalAnalysis_->Analyze(input, std::move(env)); + local = Enriched(std::move(local), global); + TNameRequest request = NameRequestFrom(input, local, global); if (request.IsEmpty()) { return NThreading::MakeFuture<TCompletion>({ @@ -128,6 +130,7 @@ namespace NSQLComplete { if (local.Function) { TFunctionName::TConstraints constraints; constraints.Namespace = local.Function->Namespace; + constraints.ReturnType = local.Function->ReturnType; request.Constraints.Function = std::move(constraints); } @@ -159,14 +162,6 @@ namespace NSQLComplete { request.Constraints.Cluster = std::move(constraints); } - if (auto name = global.EnclosingFunction.Transform(NormalizeName); - name && name == "concat") { - auto& object = request.Constraints.Object; - object = object.Defined() ? object : TObjectNameConstraints(); - object->Kinds.emplace(EObjectKind::Folder); - object->Kinds.emplace(EObjectKind::Table); - } - if (local.Column && global.Column) { TMaybe<TStringBuf> table = local.Column->Table; table = !table->empty() ? table : Nothing(); @@ -198,6 +193,31 @@ namespace NSQLComplete { return completion; } + static TLocalSyntaxContext Enriched(TLocalSyntaxContext local, const TGlobalContext& global) { + TMaybe<TFunctionContext> function = global.EnclosingFunction; + TMaybe<TLocalSyntaxContext::TObject>& object = local.Object; + if (!function || !object) { + return local; + } + + auto& name = function->Name; + size_t number = function->ArgumentNumber; + + name = NormalizeName(name); + + if (name == "concat") { + object->Kinds.emplace(EObjectKind::Folder); + object->Kinds.emplace(EObjectKind::Table); + } else if ((number == 0) && + (name == "range" || name == "like" || + name == "regexp" || name == "filter" || + name == "folder" || name == "walkfolders")) { + object->Kinds.emplace(EObjectKind::Folder); + } + + return local; + } + TConfiguration Configuration_; ILocalSyntaxAnalysis::TPtr SyntaxAnalysis_; IGlobalAnalysis::TPtr GlobalAnalysis_; |