1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#include <Interpreters/AggregateDescription.h>
#include <Common/FieldVisitorToString.h>
#include <IO/Operators.h>
#include <Common/JSONBuilder.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->getResultType()->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";
}
}
void AggregateDescription::explain(JSONBuilder::JSONMap & map) const
{
map.add("Name", column_name);
if (function)
{
auto function_map = std::make_unique<JSONBuilder::JSONMap>();
function_map->add("Name", function->getName());
const auto & params = function->getParameters();
if (!params.empty())
{
auto params_array = std::make_unique<JSONBuilder::JSONArray>();
for (const auto & param : params)
params_array->add(applyVisitor(FieldVisitorToString(), param));
function_map->add("Parameters", std::move(params_array));
}
auto args_array = std::make_unique<JSONBuilder::JSONArray>();
for (const auto & type : function->getArgumentTypes())
args_array->add(type->getName());
function_map->add("Argument Types", std::move(args_array));
function_map->add("Result Type", function->getResultType()->getName());
map.add("Function", std::move(function_map));
}
auto args_array = std::make_unique<JSONBuilder::JSONArray>();
for (const auto & name : argument_names)
args_array->add(name);
map.add("Arguments", std::move(args_array));
}
}
|