MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / validateAnalyzerSettings

Function validateAnalyzerSettings

src/Interpreters/executeQuery.cpp:996–1038  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

994}
995
996static void validateAnalyzerSettings(ASTPtr ast, bool context_value)
997{
998 if (ast->as<ASTSetQuery>())
999 return;
1000
1001 bool top_level = context_value;
1002
1003 auto field_to_bool = [](const Field & f) -> bool
1004 {
1005 if (f.getType() == Field::Types::String)
1006 return stringToBool(f.safeGet<String>());
1007 else
1008 return f.safeGet<bool>();
1009 };
1010
1011 std::vector<ASTPtr> nodes_to_process{ ast };
1012 while (!nodes_to_process.empty())
1013 {
1014 auto node = nodes_to_process.back();
1015 nodes_to_process.pop_back();
1016
1017 if (auto * set_query = node->as<ASTSetQuery>())
1018 {
1019 if (auto * value = set_query->changes.tryGet("allow_experimental_analyzer"))
1020 {
1021 if (top_level != field_to_bool(*value))
1022 throw Exception(ErrorCodes::INCORRECT_QUERY, "Setting 'allow_experimental_analyzer' is changed in the subquery. Top level value: {}", top_level);
1023 }
1024
1025 if (auto * value = set_query->changes.tryGet("enable_analyzer"))
1026 {
1027 if (top_level != field_to_bool(*value))
1028 throw Exception(ErrorCodes::INCORRECT_QUERY, "Setting 'enable_analyzer' is changed in the subquery. Top level value: {}", top_level);
1029 }
1030 }
1031
1032 for (auto child : node->children)
1033 {
1034 if (child)
1035 nodes_to_process.push_back(std::move(child));
1036 }
1037 }
1038}
1039
1040class ImplicitTransactionControlExecutor
1041{

Callers 1

executeQueryImplFunction · 0.85

Calls 8

stringToBoolFunction · 0.85
ExceptionClass · 0.70
getTypeMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
pop_backMethod · 0.45
tryGetMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected