summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/sql_ut.h
diff options
context:
space:
mode:
authorvitya-smirnov <[email protected]>2025-10-07 09:34:39 +0300
committervitya-smirnov <[email protected]>2025-10-07 09:52:14 +0300
commitbabe7533f18c11be1f8a195ed2324d2d9a89436a (patch)
tree45b7627141bf5a52b45a3d61fd1fbdd564bb8dd9 /yql/essentials/sql/v1/sql_ut.h
parent8fe7cfe254fde2772477a8933a163b5f303716b4 (diff)
YQL-20086 sql/v1
commit_hash:55bc611cdaa0d8a0fc3c4c7708ed9f17cc4976cf
Diffstat (limited to 'yql/essentials/sql/v1/sql_ut.h')
-rw-r--r--yql/essentials/sql/v1/sql_ut.h30
1 files changed, 15 insertions, 15 deletions
diff --git a/yql/essentials/sql/v1/sql_ut.h b/yql/essentials/sql/v1/sql_ut.h
index ac6e410b5dd..feb2403e39d 100644
--- a/yql/essentials/sql/v1/sql_ut.h
+++ b/yql/essentials/sql/v1/sql_ut.h
@@ -1,3 +1,4 @@
+#pragma once
#include <yql/essentials/providers/common/provider/yql_provider_names.h>
#include <yql/essentials/sql/sql.h>
@@ -35,7 +36,7 @@ inline TString Err2Str(const NYql::TAstParseResult& res, EDebugOutput debug = ED
}
inline NYql::TAstParseResult SqlToYqlWithMode(const TString& query, NSQLTranslation::ESqlMode mode = NSQLTranslation::ESqlMode::QUERY, size_t maxErrors = 10, const TString& provider = {},
- EDebugOutput debug = EDebugOutput::None, bool ansiLexer = false, NSQLTranslation::TTranslationSettings settings = {})
+ EDebugOutput debug = EDebugOutput::None, bool ansiLexer = false, NSQLTranslation::TTranslationSettings settings = {})
{
google::protobuf::Arena arena;
const auto service = provider ? provider : TString(NYql::YtProviderName);
@@ -60,8 +61,7 @@ inline NYql::TAstParseResult SqlToYqlWithMode(const TString& query, NSQLTranslat
NSQLTranslation::TTranslators translators(
nullptr,
NSQLTranslationV1::MakeTranslator(lexers, parsers),
- nullptr
- );
+ nullptr);
auto res = SqlToYql(translators, query, settings);
if (debug == EDebugOutput::ToCerr) {
@@ -118,7 +118,7 @@ inline TString Quote(const char* str) {
class TWordCountHive: public TMap<TString, unsigned> {
public:
TWordCountHive(std::initializer_list<TString> strings) {
- for (auto& str: strings) {
+ for (auto& str : strings) {
emplace(str, 0);
}
}
@@ -129,14 +129,14 @@ public:
}
};
-typedef std::function<void (const TString& word, const TString& line)> TVerifyLineFunc;
+typedef std::function<void(const TString& word, const TString& line)> TVerifyLineFunc;
inline TString VerifyProgram(const NYql::TAstParseResult& res, TWordCountHive& wordCounter, TVerifyLineFunc verifyLine = TVerifyLineFunc()) {
const auto program = GetPrettyPrint(res);
TVector<TString> yqlProgram;
Split(program, "\n", yqlProgram);
- for (const auto& line: yqlProgram) {
- for (auto& counterIter: wordCounter) {
+ for (const auto& line : yqlProgram) {
+ for (auto& counterIter : wordCounter) {
const auto& word = counterIter.first;
auto pos = line.find(word);
while (pos != TString::npos) {
@@ -154,8 +154,7 @@ inline TString VerifyProgram(const NYql::TAstParseResult& res, TWordCountHive& w
inline void VerifySqlInHints(const TString& query, const THashSet<TString>& expectedHints, TMaybe<bool> ansi) {
TString pragma;
if (ansi.Defined()) {
- pragma = *ansi ? "PRAGMA AnsiInForEmptyOrNullableItemsCollections;" :
- "PRAGMA DisableAnsiInForEmptyOrNullableItemsCollections;";
+ pragma = *ansi ? "PRAGMA AnsiInForEmptyOrNullableItemsCollections;" : "PRAGMA DisableAnsiInForEmptyOrNullableItemsCollections;";
}
NYql::TAstParseResult res = SqlToYql(pragma + query);
@@ -168,7 +167,7 @@ inline void VerifySqlInHints(const TString& query, const THashSet<TString>& expe
} else if (*ansi) {
UNIT_ASSERT_VALUES_UNEQUAL(TString::npos, line.find("'('ansi)"));
}
- for (auto& hint : expectedHints) {
+ for (auto& hint : expectedHints) {
UNIT_ASSERT_VALUES_UNEQUAL(TString::npos, line.find(hint));
}
};
@@ -221,14 +220,15 @@ inline NSQLTranslation::TTranslationSettings GetSettingsWithS3Binding(const TStr
return settings;
}
-inline void AstBfs(NYql::TAstNode const* root, std::function<bool (NYql::TAstNode const*)> visitor) {
- std::deque<NYql::TAstNode const*> wishList{ root };
+inline void AstBfs(NYql::TAstNode const* root, std::function<bool(NYql::TAstNode const*)> visitor) {
+ std::deque<NYql::TAstNode const*> wishList{root};
std::unordered_set<NYql::TAstNode const*> visited;
- while(!wishList.empty()){
+ while (!wishList.empty()) {
auto v = wishList.front();
wishList.pop_front();
- if (!visitor(v))
+ if (!visitor(v)) {
return;
+ }
visited.insert(v);
if (v->IsList()) {
for (ui32 i = 0; i != v->GetChildrenCount(); ++i) {
@@ -241,7 +241,7 @@ inline void AstBfs(NYql::TAstNode const* root, std::function<bool (NYql::TAstNod
}
}
-inline const NYql::TAstNode* FindNodeByChildAtomContent(const NYql::TAstNode* root, uint32_t childIndex, TStringBuf name){
+inline const NYql::TAstNode* FindNodeByChildAtomContent(const NYql::TAstNode* root, uint32_t childIndex, TStringBuf name) {
const NYql::TAstNode* result = nullptr;
AstBfs(root, [&result, childIndex, name](auto v) {
if (v->IsList() && v->GetChildrenCount() > childIndex &&