diff options
author | vityaman <[email protected]> | 2025-05-23 18:39:07 +0300 |
---|---|---|
committer | robot-piglet <[email protected]> | 2025-05-23 18:56:51 +0300 |
commit | 7c0f642f72f590d66d364c59e77ab1a7e4d7fcf2 (patch) | |
tree | f278253c47fb2749b353d7b31ad593ef2be92899 /yql/essentials/sql/v1/complete/sql_complete.cpp | |
parent | bed215f88992e53d74c041c0908555bbd70033ab (diff) |
YQL-19747: Support statement blacklist
I leaved the YDB configuration empty as need your feedback.
---
- Related to `YQL-19747`
- Related to https://github.com/vityaman/ydb/issues/39
---
Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1289
commit_hash:408c7e0f101027fc6ca3d86d251b5639fcae07bb
Diffstat (limited to 'yql/essentials/sql/v1/complete/sql_complete.cpp')
-rw-r--r-- | yql/essentials/sql/v1/complete/sql_complete.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/yql/essentials/sql/v1/complete/sql_complete.cpp b/yql/essentials/sql/v1/complete/sql_complete.cpp index 00d346f0770..99388cb9304 100644 --- a/yql/essentials/sql/v1/complete/sql_complete.cpp +++ b/yql/essentials/sql/v1/complete/sql_complete.cpp @@ -1,5 +1,6 @@ #include "sql_complete.h" +#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/static/name_service.h> #include <yql/essentials/sql/v1/complete/syntax/local.h> @@ -18,7 +19,7 @@ namespace NSQLComplete { INameService::TPtr names, ISqlCompletionEngine::TConfiguration configuration) : Configuration_(std::move(configuration)) - , SyntaxAnalysis_(MakeLocalSyntaxAnalysis(lexer)) + , SyntaxAnalysis_(MakeLocalSyntaxAnalysis(lexer, Configuration_.IgnoredRules)) , GlobalAnalysis_(MakeGlobalAnalysis()) , Names_(std::move(names)) { @@ -213,6 +214,41 @@ namespace NSQLComplete { INameService::TPtr Names_; }; + ISqlCompletionEngine::TConfiguration MakeYDBConfiguration() { + return {}; + } + + ISqlCompletionEngine::TConfiguration MakeYQLConfiguration() { + std::unordered_set<std::string> whitelist = { + "lambda_stmt", + "sql_stmt", + "pragma_stmt", + "select_stmt", + "named_nodes_stmt", + "drop_table_stmt", + "use_stmt", + "into_table_stmt", + "commit_stmt", + "declare_stmt", + "import_stmt", + "export_stmt", + "do_stmt", + "define_action_or_subquery_stmt", + "if_stmt", + "for_stmt", + "values_stmt", + }; + + ISqlCompletionEngine::TConfiguration config; + for (const std::string& name : GetSqlGrammar().GetAllRules()) { + if (name.ends_with("_stmt") && !whitelist.contains(name)) { + config.IgnoredRules.emplace(name); + } + } + + return config; + } + ISqlCompletionEngine::TPtr MakeSqlCompletionEngine( TLexerSupplier lexer, INameService::TPtr names, |