ClickHouse/src/Interpreters/AggregateDescription.cpp

103 lines
2.0 KiB
C++
Raw Normal View History

#include <Interpreters/AggregateDescription.h>
#include <Common/FieldVisitors.h>
2020-06-27 14:02:24 +00:00
#include <IO/Operators.h>
namespace DB
{
2020-07-07 19:51:32 +00:00
void AggregateDescription::explain(WriteBuffer & out, size_t indent) const
{
2020-07-07 19:51:32 +00:00
String prefix(indent, ' ');
2020-06-27 14:02:24 +00:00
out << prefix << column_name << '\n';
2020-06-27 14:02:24 +00:00
auto dump_params = [&](const Array & arr)
{
2020-06-27 14:02:24 +00:00
bool first = true;
for (const auto & param : arr)
{
2020-06-27 14:02:24 +00:00
if (!first)
out << ", ";
2020-06-27 14:02:24 +00:00
first = false;
2020-06-27 14:02:24 +00:00
out << applyVisitor(FieldVisitorToString(), param);
}
};
if (function)
{
2020-07-05 16:27:54 +00:00
/// Double whitespace is intentional.
2020-06-27 14:02:24 +00:00
out << prefix << " Function: " << function->getName();
const auto & params = function->getParameters();
if (!params.empty())
{
out << "(";
dump_params(params);
out << ")";
}
out << "(";
bool first = true;
for (const auto & type : function->getArgumentTypes())
{
2020-06-27 14:02:24 +00:00
if (!first)
out << ", ";
first = false;
2020-06-27 14:02:24 +00:00
out << type->getName();
}
2020-06-29 20:23:34 +00:00
out << ") → " << function->getReturnType()->getName() << "\n";
}
else
2020-06-27 14:02:24 +00:00
out << prefix << " Function: nullptr\n";
if (!parameters.empty())
2020-06-24 12:09:01 +00:00
{
2020-06-27 14:02:24 +00:00
out << prefix << " Parameters: ";
dump_params(parameters);
out << '\n';
2020-06-24 12:09:01 +00:00
}
2020-06-27 14:02:24 +00:00
out << prefix << " Arguments: ";
2020-06-24 12:09:01 +00:00
2020-06-27 14:02:24 +00:00
if (argument_names.empty())
out << "none\n";
else
2020-06-24 12:09:01 +00:00
{
2020-06-27 14:02:24 +00:00
bool first = true;
for (const auto & arg : argument_names)
{
if (!first)
out << ", ";
first = false;
2020-06-24 12:09:01 +00:00
2020-06-27 14:02:24 +00:00
out << arg;
}
out << "\n";
2020-06-24 12:09:01 +00:00
}
2020-06-27 14:02:24 +00:00
out << prefix << " Argument positions: ";
2020-06-24 12:09:01 +00:00
2020-06-27 14:02:24 +00:00
if (arguments.empty())
out << "none\n";
else
{
bool first = true;
for (auto arg : arguments)
{
if (!first)
out << ", ";
first = false;
2020-06-27 14:02:24 +00:00
out << arg;
}
out << '\n';
}
}
}