ClickHouse/src/Parsers/formatSettingName.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
855 B
C++
Raw Normal View History

#include <Parsers/formatSettingName.h>
#include <Common/StringUtils/StringUtils.h>
#include <Common/quoteString.h>
2021-10-02 07:13:14 +00:00
#include <base/find_symbols.h>
2020-11-09 16:05:40 +00:00
#include <IO/Operators.h>
namespace DB
{
2020-11-09 16:05:40 +00:00
void formatSettingName(const String & setting_name, WriteBuffer & out)
{
if (isValidIdentifier(setting_name))
{
out << setting_name;
return;
}
std::vector<std::string_view> parts;
splitInto<'.'>(parts, setting_name);
bool all_parts_are_identifiers = std::all_of(parts.begin(), parts.end(), isValidIdentifier);
if (all_parts_are_identifiers && !parts.empty())
{
bool need_dot = false;
for (const auto & part : parts)
{
if (std::exchange(need_dot, true))
out << ".";
out << part;
}
return;
}
out << backQuote(setting_name);
}
}