diff options
author | vityaman <vityaman.dev@yandex.ru> | 2025-05-06 15:49:02 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2025-05-06 16:04:08 +0300 |
commit | 9c3fdca51d8ae892c5ad8f6ef92df73fafc09e28 (patch) | |
tree | 561c599fae4ea29b537a6958b65e1b052548edf2 /yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp | |
parent | c131e959456f9f9a4adada5623ce3bae4097a8c1 (diff) | |
download | ydb-9c3fdca51d8ae892c5ad8f6ef92df73fafc09e28.tar.gz |
YQL-19747 Complete folder, table and cluster names
---
- Related to `YQL-19747`
- On top of https://github.com/ytsaurus/ytsaurus/pull/1253
- Related to https://github.com/ydb-platform/ydb/issues/9056
- Related to https://github.com/vityaman/ydb/issues/14
- Related to https://github.com/vityaman/ydb/issues/35
- Related to https://github.com/vityaman/ydb/issues/40
---
Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1257
commit_hash:0b842abb27184c88b8177beeea29fb1ea86b7a04
Diffstat (limited to 'yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp')
-rw-r--r-- | yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp b/yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp index 938483438b1..ce6c94306d4 100644 --- a/yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp +++ b/yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp @@ -13,7 +13,7 @@ namespace NSQLComplete { - const TVector<TRuleId> KeywordRules = { + const TVector<TRuleId> PreferredRules = { RULE(Keyword), RULE(Keyword_expr_uncompat), RULE(Keyword_table_uncompat), @@ -24,27 +24,13 @@ namespace NSQLComplete { RULE(Keyword_hint_uncompat), RULE(Keyword_as_compat), RULE(Keyword_compat), - }; - - const TVector<TRuleId> PragmaNameRules = { - RULE(Opt_id_prefix_or_type), - RULE(An_id), - }; - - const TVector<TRuleId> TypeNameRules = { - RULE(Type_name_simple), RULE(An_id_or_type), - }; - - const TVector<TRuleId> FunctionNameRules = { + RULE(An_id), RULE(Id_expr), - RULE(An_id_or_type), RULE(Id_or_type), - }; - - const TVector<TRuleId> HintNameRules = { RULE(Id_hint), - RULE(An_id), + RULE(Opt_id_prefix_or_type), + RULE(Type_name_simple), }; TVector<std::string> Symbolized(const TParserCallStack& stack) { @@ -101,6 +87,26 @@ namespace NSQLComplete { Contains({RULE(External_call_param), RULE(An_id)}, stack); } + bool IsLikelyObjectRefStack(const TParserCallStack& stack) { + return Contains({RULE(Object_ref)}, stack); + } + + bool IsLikelyExistingTableStack(const TParserCallStack& stack) { + return !Contains({RULE(Create_table_stmt), + RULE(Simple_table_ref)}, stack) && + (Contains({RULE(Simple_table_ref), + RULE(Simple_table_ref_core), + RULE(Object_ref)}, stack) || + Contains({RULE(Single_source), + RULE(Table_ref), + RULE(Table_key), + RULE(Id_table_or_type)}, stack)); + } + + bool IsLikelyClusterStack(const TParserCallStack& stack) { + return Contains({RULE(Cluster_expr)}, stack); + } + TMaybe<EStatementKind> StatementKindOf(const TParserCallStack& stack) { for (TRuleId rule : std::ranges::views::reverse(stack)) { if (rule == RULE(Process_core) || rule == RULE(Reduce_core) || rule == RULE(Select_core)) { @@ -115,10 +121,7 @@ namespace NSQLComplete { std::unordered_set<TRuleId> GetC3PreferredRules() { std::unordered_set<TRuleId> preferredRules; - preferredRules.insert(std::begin(KeywordRules), std::end(KeywordRules)); - preferredRules.insert(std::begin(PragmaNameRules), std::end(PragmaNameRules)); - preferredRules.insert(std::begin(TypeNameRules), std::end(TypeNameRules)); - preferredRules.insert(std::begin(FunctionNameRules), std::end(FunctionNameRules)); + preferredRules.insert(std::begin(PreferredRules), std::end(PreferredRules)); return preferredRules; } |