diff options
| author | vitya-smirnov <[email protected]> | 2025-10-07 09:34:39 +0300 |
|---|---|---|
| committer | vitya-smirnov <[email protected]> | 2025-10-07 09:52:14 +0300 |
| commit | babe7533f18c11be1f8a195ed2324d2d9a89436a (patch) | |
| tree | 45b7627141bf5a52b45a3d61fd1fbdd564bb8dd9 /yql/essentials/sql/v1/sql_translation.h | |
| parent | 8fe7cfe254fde2772477a8933a163b5f303716b4 (diff) | |
YQL-20086 sql/v1
commit_hash:55bc611cdaa0d8a0fc3c4c7708ed9f17cc4976cf
Diffstat (limited to 'yql/essentials/sql/v1/sql_translation.h')
| -rw-r--r-- | yql/essentials/sql/v1/sql_translation.h | 93 |
1 files changed, 46 insertions, 47 deletions
diff --git a/yql/essentials/sql/v1/sql_translation.h b/yql/essentials/sql/v1/sql_translation.h index 6858ee3a588..5c56b2537f0 100644 --- a/yql/essentials/sql/v1/sql_translation.h +++ b/yql/essentials/sql/v1/sql_translation.h @@ -80,7 +80,7 @@ TString Id(const TRule_an_id_hint& node, TTranslation& ctx); TString Id(const TRule_an_id_pure& node, TTranslation& ctx); -template<typename TRule> +template <typename TRule> inline TIdentifier IdEx(const TRule& node, TTranslation& ctx) { const TString name(Id(node, ctx)); const TPosition pos(ctx.Context().Pos()); @@ -147,7 +147,7 @@ protected: bool ActionOrSubqueryArgs(const TRule_action_or_subquery_args& node, TVector<TSymbolNameWithPos>& bindNames, ui32& optionalArgsCount); bool ModulePath(const TRule_module_path& node, TVector<TString>& path); bool NamedBindList(const TRule_named_bind_parameter_list& node, TVector<TSymbolNameWithPos>& names, - TVector<TSymbolNameWithPos>& aliases); + TVector<TSymbolNameWithPos>& aliases); bool NamedBindParam(const TRule_named_bind_parameter& node, TSymbolNameWithPos& name, TSymbolNameWithPos& alias); TNodePtr NamedNode(const TRule_named_nodes_stmt& rule, TVector<TSymbolNameWithPos>& names); @@ -171,11 +171,11 @@ protected: bool FillFamilySettings(const TRule_family_settings& settingsNode, TFamilyEntry& family); bool CreateTableSettings(const TRule_with_table_settings& settingsNode, TCreateTableParameters& params); bool StoreTableSettingsEntry(const TIdentifier& id, const TRule_table_setting_value* value, TTableSettings& settings, - ETableType tableType, bool alter, bool reset); + ETableType tableType, bool alter, bool reset); bool StoreTableSettingsEntry(const TIdentifier& id, const TRule_table_setting_value* value, TTableSettings& settings, - bool alter, bool reset); + bool alter, bool reset); bool StoreExternalTableSettingsEntry(const TIdentifier& id, const TRule_table_setting_value* value, TTableSettings& settings, - bool alter, bool reset); + bool alter, bool reset); bool StoreTableSettingsEntry(const TIdentifier& id, const TRule_table_setting_value& value, TTableSettings& settings, ETableType tableType, bool alter = false); bool StoreDataSourceSettingsEntry(const TIdentifier& id, const TRule_table_setting_value* value, std::map<TString, TDeferredAtom>& result); bool StoreDataSourceSettingsEntry(const TRule_alter_table_setting_entry& entry, std::map<TString, TDeferredAtom>& result); @@ -192,7 +192,7 @@ protected: bool FillIndexSettings(const TRule_with_index_settings& settingsNode, TIndexDescription::TIndexSettings& indexSettings); bool AddIndexSetting(const TIdentifier& id, const TRule_index_setting_value& value, TIndexDescription::TIndexSettings& indexSettings); TString GetIndexSettingStringValue(const TRule_index_setting_value& node); - template<typename T> + template <typename T> std::tuple<bool, T, TString> GetIndexSettingValue(const TRule_index_setting_value& node); TIdentifier GetTopicConsumerId(const TRule_topic_consumer_ref& node); @@ -208,10 +208,8 @@ protected: bool AlterTopicConsumerEntry(const TRule_alter_topic_alter_consumer_entry& node, TTopicConsumerDescription& alterConsumer); - bool AlterTopicAction(const TRule_alter_topic_action& node, TAlterTopicParameters& params); - TNodePtr TypeSimple(const TRule_type_name_simple& node, bool onlyDataAllowed); TNodePtr TypeDecimal(const TRule_type_name_decimal& node); TNodePtr AddOptionals(const TNodePtr& node, size_t optionalCount); @@ -292,6 +290,7 @@ protected: bool ValidateExternalTable(const TCreateTableParameters& params); TNodePtr ReturningList(const ::NSQLv1Generated::TRule_returning_columns_list& columns); + private: bool SimpleTableRefCoreImpl(const TRule_simple_table_ref_core& node, TTableRef& result); static bool IsValidFrameSettings(TContext& ctx, const TFrameSpecification& frameSpec, size_t sortSpecSize); @@ -314,54 +313,54 @@ TNodePtr LiteralNumber(TContext& ctx, const TRule_integer& node); bool StoreString(const TRule_family_setting_value& from, TNodePtr& to, TContext& ctx); bool StoreInt(const TRule_family_setting_value& from, TNodePtr& to, TContext& ctx); -template<typename TChar> +template <typename TChar> struct TPatternComponent { - TBasicString<TChar> Prefix; - TBasicString<TChar> Suffix; - bool IsSimple = true; + TBasicString<TChar> Prefix; + TBasicString<TChar> Suffix; + bool IsSimple = true; - void AppendPlain(TChar c) { - if (IsSimple) { - Prefix.push_back(c); - } - Suffix.push_back(c); + void AppendPlain(TChar c) { + if (IsSimple) { + Prefix.push_back(c); } + Suffix.push_back(c); + } - void AppendAnyChar() { - IsSimple = false; - Suffix.clear(); - } + void AppendAnyChar() { + IsSimple = false; + Suffix.clear(); + } }; -template<typename TChar> +template <typename TChar> TVector<TPatternComponent<TChar>> SplitPattern(const TBasicString<TChar>& pattern, TMaybe<char> escape, bool& inEscape) { - inEscape = false; - TVector<TPatternComponent<TChar>> result; - TPatternComponent<TChar> current; - bool prevIsPercentChar = false; - for (const TChar c : pattern) { - if (inEscape) { - current.AppendPlain(c); - inEscape = false; - prevIsPercentChar = false; - } else if (escape && c == static_cast<TChar>(*escape)) { - inEscape = true; - } else if (c == '%') { - if (!prevIsPercentChar) { - result.push_back(std::move(current)); - } - current = {}; - prevIsPercentChar = true; - } else if (c == '_') { - current.AppendAnyChar(); - prevIsPercentChar = false; - } else { - current.AppendPlain(c); - prevIsPercentChar = false; + inEscape = false; + TVector<TPatternComponent<TChar>> result; + TPatternComponent<TChar> current; + bool prevIsPercentChar = false; + for (const TChar c : pattern) { + if (inEscape) { + current.AppendPlain(c); + inEscape = false; + prevIsPercentChar = false; + } else if (escape && c == static_cast<TChar>(*escape)) { + inEscape = true; + } else if (c == '%') { + if (!prevIsPercentChar) { + result.push_back(std::move(current)); } + current = {}; + prevIsPercentChar = true; + } else if (c == '_') { + current.AppendAnyChar(); + prevIsPercentChar = false; + } else { + current.AppendPlain(c); + prevIsPercentChar = false; } - result.push_back(std::move(current)); - return result; + } + result.push_back(std::move(current)); + return result; } bool ParseNumbers(TContext& ctx, const TString& strOrig, ui64& value, TString& suffix); |
