mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-18 13:42:02 +00:00
131 lines
2.9 KiB
C++
131 lines
2.9 KiB
C++
#include <Interpreters/AggregateDescription.h>
|
|
#include <Common/FieldVisitors.h>
|
|
#include <IO/Operators.h>
|
|
#include <Parsers/ASTFunction.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
void AggregateDescription::explain(WriteBuffer & out, size_t indent) const
|
|
{
|
|
String prefix(indent, ' ');
|
|
|
|
out << prefix << column_name << '\n';
|
|
|
|
auto dump_params = [&](const Array & arr)
|
|
{
|
|
bool first = true;
|
|
for (const auto & param : arr)
|
|
{
|
|
if (!first)
|
|
out << ", ";
|
|
|
|
first = false;
|
|
|
|
out << applyVisitor(FieldVisitorToString(), param);
|
|
}
|
|
};
|
|
|
|
if (function)
|
|
{
|
|
/// Double whitespace is intentional.
|
|
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())
|
|
{
|
|
if (!first)
|
|
out << ", ";
|
|
first = false;
|
|
|
|
out << type->getName();
|
|
}
|
|
|
|
out << ") → " << function->getReturnType()->getName() << "\n";
|
|
}
|
|
else
|
|
out << prefix << " Function: nullptr\n";
|
|
|
|
if (!parameters.empty())
|
|
{
|
|
out << prefix << " Parameters: ";
|
|
dump_params(parameters);
|
|
out << '\n';
|
|
}
|
|
|
|
out << prefix << " Arguments: ";
|
|
|
|
if (argument_names.empty())
|
|
out << "none\n";
|
|
else
|
|
{
|
|
bool first = true;
|
|
for (const auto & arg : argument_names)
|
|
{
|
|
if (!first)
|
|
out << ", ";
|
|
first = false;
|
|
|
|
out << arg;
|
|
}
|
|
out << "\n";
|
|
}
|
|
|
|
out << prefix << " Argument positions: ";
|
|
|
|
if (arguments.empty())
|
|
out << "none\n";
|
|
else
|
|
{
|
|
bool first = true;
|
|
for (auto arg : arguments)
|
|
{
|
|
if (!first)
|
|
out << ", ";
|
|
first = false;
|
|
|
|
out << arg;
|
|
}
|
|
out << '\n';
|
|
}
|
|
}
|
|
|
|
std::string WindowFunctionDescription::dump() const
|
|
{
|
|
WriteBufferFromOwnString ss;
|
|
|
|
ss << "window function '" << column_name << "' over '" << window_name <<"\n";
|
|
ss << "function node " << function_node->dumpTree() << "\n";
|
|
ss << "aggregate function '" << aggregate_function->getName() << "'\n";
|
|
if (!function_parameters.empty())
|
|
{
|
|
ss << "parameters " << toString(function_parameters) << "\n";
|
|
}
|
|
|
|
return ss.str();
|
|
}
|
|
|
|
std::string WindowDescription::dump() const
|
|
{
|
|
WriteBufferFromOwnString ss;
|
|
|
|
ss << "window '" << window_name << "'\n";
|
|
ss << "partition_by " << dumpSortDescription(partition_by) << "\n";
|
|
ss << "order_by " << dumpSortDescription(order_by) << "\n";
|
|
ss << "full_sort_description " << dumpSortDescription(full_sort_description) << "\n";
|
|
|
|
return ss.str();
|
|
}
|
|
|
|
}
|