2020-06-23 16:06:56 +00:00
|
|
|
#include <Interpreters/AggregateDescription.h>
|
|
|
|
#include <Common/FieldVisitors.h>
|
2020-06-27 14:02:24 +00:00
|
|
|
#include <IO/Operators.h>
|
2020-06-23 16:06:56 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-06-27 14:02:24 +00:00
|
|
|
void AggregateDescription::explain(WriteBuffer & out, size_t ident) const
|
2020-06-23 16:06:56 +00:00
|
|
|
{
|
2020-06-27 14:02:24 +00:00
|
|
|
String prefix(ident, ' ');
|
2020-06-23 16:06:56 +00:00
|
|
|
|
2020-06-27 14:02:24 +00:00
|
|
|
out << prefix << column_name << '\n';
|
2020-06-23 16:06:56 +00:00
|
|
|
|
2020-06-27 14:02:24 +00:00
|
|
|
auto dump_params = [&](const Array & arr)
|
2020-06-23 16:06:56 +00:00
|
|
|
{
|
2020-06-27 14:02:24 +00:00
|
|
|
bool first = true;
|
2020-06-23 16:06:56 +00:00
|
|
|
for (const auto & param : arr)
|
|
|
|
{
|
2020-06-27 14:02:24 +00:00
|
|
|
if (!first)
|
|
|
|
out << ", ";
|
2020-06-23 16:06:56 +00:00
|
|
|
|
2020-06-27 14:02:24 +00:00
|
|
|
first = false;
|
2020-06-23 16:06:56 +00:00
|
|
|
|
2020-06-27 14:02:24 +00:00
|
|
|
out << applyVisitor(FieldVisitorToString(), param);
|
|
|
|
}
|
2020-06-23 16:06:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (function)
|
|
|
|
{
|
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;
|
2020-06-23 16:06:56 +00:00
|
|
|
for (const auto & type : function->getArgumentTypes())
|
|
|
|
{
|
2020-06-27 14:02:24 +00:00
|
|
|
if (!first)
|
|
|
|
out << ", ";
|
|
|
|
first = false;
|
2020-06-23 16:06:56 +00:00
|
|
|
|
2020-06-27 14:02:24 +00:00
|
|
|
out << type->getName();
|
2020-06-23 16:06:56 +00:00
|
|
|
}
|
|
|
|
|
2020-06-27 14:02:24 +00:00
|
|
|
out << ")\n";
|
2020-06-23 16:06:56 +00:00
|
|
|
}
|
|
|
|
else
|
2020-06-27 14:02:24 +00:00
|
|
|
out << prefix << " Function: nullptr\n";
|
2020-06-23 16:06:56 +00:00
|
|
|
|
|
|
|
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-23 16:06:56 +00:00
|
|
|
|
2020-06-27 14:02:24 +00:00
|
|
|
out << arg;
|
|
|
|
}
|
|
|
|
out << '\n';
|
|
|
|
}
|
2020-06-23 16:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|