aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp
diff options
context:
space:
mode:
authorvityaman <vityaman.dev@yandex.ru>2025-04-09 17:57:35 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2025-04-09 18:12:05 +0300
commit394fee4aa8d48e58cf82c72bcb9dda0a5dd50190 (patch)
tree48fee02cc78dd77aaf1e5e96f2c1a70bd41dfb5d /yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp
parent0fd1b879589ea8263582a184ccbeac61fd38b596 (diff)
downloadydb-394fee4aa8d48e58cf82c72bcb9dda0a5dd50190.tar.gz
YQL-19747 Complete select and insert hints
- Related to https://github.com/ydb-platform/ydb/issues/9056 - Related to https://github.com/vityaman/ydb/issues/19 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1189 commit_hash:7f1cb1dcf0617aa2c94c3f2188fc9bd481380252
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.cpp22
1 files changed, 22 insertions, 0 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 1bfcac47266..bbe0b3d371c 100644
--- a/yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp
+++ b/yql/essentials/sql/v1/complete/syntax/parser_call_stack.cpp
@@ -6,6 +6,8 @@
#include <util/generic/algorithm.h>
#include <util/generic/yexception.h>
+#include <ranges>
+
#define DEBUG_SYMBOLIZE_STACK(stack) \
auto debug_symbolized_##stack = Symbolized(stack)
@@ -40,6 +42,10 @@ namespace NSQLComplete {
RULE(Id_or_type),
};
+ const TVector<TRuleId> HintNameRules = {
+ RULE(Id_hint),
+ };
+
TVector<std::string> Symbolized(const TParserCallStack& stack) {
const ISqlGrammar& grammar = GetSqlGrammar();
@@ -89,6 +95,22 @@ namespace NSQLComplete {
EndsWith({RULE(Atom_expr), RULE(Id_or_type)}, stack);
}
+ bool IsLikelyHintStack(const TParserCallStack& stack) {
+ return ContainsRule(RULE(Id_hint), stack);
+ }
+
+ std::optional<EStatementKind> StatementKindOf(const TParserCallStack& stack) {
+ for (TRuleId rule : std::ranges::views::reverse(stack)) {
+ if (rule == RULE(Select_core)) {
+ return EStatementKind::Select;
+ }
+ if (rule == RULE(Into_table_stmt)) {
+ return EStatementKind::Insert;
+ }
+ }
+ return std::nullopt;
+ }
+
std::unordered_set<TRuleId> GetC3PreferredRules() {
std::unordered_set<TRuleId> preferredRules;
preferredRules.insert(std::begin(KeywordRules), std::end(KeywordRules));