ClickHouse/src/Parsers/ASTFunctionWithKeyValueArguments.cpp

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

104 lines
2.6 KiB
C++
Raw Normal View History

2019-10-01 14:54:28 +00:00
#include <Parsers/ASTFunctionWithKeyValueArguments.h>
#include <Poco/String.h>
2020-08-20 02:01:40 +00:00
#include <Common/SipHash.h>
2020-11-09 16:05:40 +00:00
#include <IO/Operators.h>
2019-10-01 14:54:28 +00:00
namespace DB
{
String ASTPair::getID(char) const
{
return "pair";
}
ASTPtr ASTPair::clone() const
{
auto res = std::make_shared<ASTPair>(*this);
res->children.clear();
2020-08-05 02:21:33 +00:00
res->set(res->second, second->clone());
2019-10-01 14:54:28 +00:00
return res;
}
void ASTPair::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << Poco::toUpper(first) << " " << (settings.hilite ? hilite_none : "");
2019-10-08 09:47:17 +00:00
if (second_with_brackets)
settings.ostr << (settings.hilite ? hilite_keyword : "") << "(";
if (!settings.show_secrets && (first == "password"))
{
/// Hide password in the definition of a dictionary:
/// SOURCE(CLICKHOUSE(host 'example01-01-1' port 9000 user 'default' password '[HIDDEN]' db 'default' table 'ids'))
settings.ostr << "'[HIDDEN]'";
}
else
{
second->formatImpl(settings, state, frame);
}
2019-10-08 09:47:17 +00:00
if (second_with_brackets)
settings.ostr << (settings.hilite ? hilite_keyword : "") << ")";
2019-10-01 14:54:28 +00:00
settings.ostr << (settings.hilite ? hilite_none : "");
}
2020-08-20 02:01:40 +00:00
bool ASTPair::hasSecretParts() const
{
return first == "password";
}
2020-08-20 02:01:40 +00:00
void ASTPair::updateTreeHashImpl(SipHash & hash_state) const
{
hash_state.update(first.size());
hash_state.update(first);
hash_state.update(second_with_brackets);
IAST::updateTreeHashImpl(hash_state);
}
2019-10-01 14:54:28 +00:00
String ASTFunctionWithKeyValueArguments::getID(char delim) const
{
return "FunctionWithKeyValueArguments " + (delim + name);
}
ASTPtr ASTFunctionWithKeyValueArguments::clone() const
{
auto res = std::make_shared<ASTFunctionWithKeyValueArguments>(*this);
res->children.clear();
if (elements)
{
2020-08-05 02:21:33 +00:00
res->elements = elements->clone();
2019-10-01 14:54:28 +00:00
res->children.push_back(res->elements);
}
return res;
}
void ASTFunctionWithKeyValueArguments::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << Poco::toUpper(name) << (settings.hilite ? hilite_none : "") << (has_brackets ? "(" : "");
2019-10-01 14:54:28 +00:00
elements->formatImpl(settings, state, frame);
settings.ostr << (has_brackets ? ")" : "");
2019-10-01 14:54:28 +00:00
settings.ostr << (settings.hilite ? hilite_none : "");
}
2020-08-20 02:01:40 +00:00
void ASTFunctionWithKeyValueArguments::updateTreeHashImpl(SipHash & hash_state) const
{
hash_state.update(name.size());
hash_state.update(name);
hash_state.update(has_brackets);
IAST::updateTreeHashImpl(hash_state);
}
2019-10-01 14:54:28 +00:00
}