|
1 | 1 | #include "utils.h"
|
2 | 2 |
|
3 | 3 | #include <clickhouse/block.h>
|
| 4 | +#include <clickhouse/client.h> |
4 | 5 | #include <clickhouse/columns/column.h>
|
5 | 6 | #include <clickhouse/columns/array.h>
|
6 | 7 | #include <clickhouse/columns/date.h>
|
@@ -154,28 +155,6 @@ std::ostream & operator<<(std::ostream & ostr, const ColumnValue& v) {
|
154 | 155 |
|
155 | 156 | }
|
156 | 157 |
|
157 |
| -std::ostream& operator<<(std::ostream & ostr, const Block & block) { |
158 |
| - if (block.GetRowCount() == 0 || block.GetColumnCount() == 0) |
159 |
| - return ostr; |
160 |
| - |
161 |
| - for (size_t col = 0; col < block.GetColumnCount(); ++col) { |
162 |
| - const auto & c = block[col]; |
163 |
| - ostr << c->GetType().GetName() << " ["; |
164 |
| - |
165 |
| - for (size_t row = 0; row < block.GetRowCount(); ++row) { |
166 |
| - printColumnValue(c, row, ostr); |
167 |
| - if (row != block.GetRowCount() - 1) |
168 |
| - ostr << ", "; |
169 |
| - } |
170 |
| - ostr << "]"; |
171 |
| - |
172 |
| - if (col != block.GetColumnCount() - 1) |
173 |
| - ostr << "\n"; |
174 |
| - } |
175 |
| - |
176 |
| - return ostr; |
177 |
| -} |
178 |
| - |
179 | 158 | std::ostream& operator<<(std::ostream & ostr, const PrettyPrintBlock & pretty_print_block) {
|
180 | 159 | // Pretty-print block:
|
181 | 160 | // - names of each column
|
@@ -249,7 +228,41 @@ std::ostream& operator<<(std::ostream& ostr, const in6_addr& addr) {
|
249 | 228 | return ostr << ip_str;
|
250 | 229 | }
|
251 | 230 |
|
252 |
| -std::ostream& operator<<(std::ostream & ostr, const clickhouse::Type & type) { |
| 231 | +namespace clickhouse { |
| 232 | + |
| 233 | +std::ostream& operator<<(std::ostream & ostr, const Block & block) { |
| 234 | + if (block.GetRowCount() == 0 || block.GetColumnCount() == 0) |
| 235 | + return ostr; |
| 236 | + |
| 237 | + for (size_t col = 0; col < block.GetColumnCount(); ++col) { |
| 238 | + const auto & c = block[col]; |
| 239 | + ostr << c->GetType().GetName() << " ["; |
| 240 | + |
| 241 | + for (size_t row = 0; row < block.GetRowCount(); ++row) { |
| 242 | + printColumnValue(c, row, ostr); |
| 243 | + if (row != block.GetRowCount() - 1) |
| 244 | + ostr << ", "; |
| 245 | + } |
| 246 | + ostr << "]"; |
| 247 | + |
| 248 | + if (col != block.GetColumnCount() - 1) |
| 249 | + ostr << "\n"; |
| 250 | + } |
| 251 | + |
| 252 | + return ostr; |
| 253 | +} |
| 254 | + |
| 255 | +std::ostream& operator<<(std::ostream & ostr, const Type & type) { |
253 | 256 | return ostr << type.GetName();
|
254 | 257 | }
|
255 | 258 |
|
| 259 | +std::ostream & operator<<(std::ostream & ostr, const ServerInfo & server_info) { |
| 260 | + return ostr << server_info.name << "/" << server_info.display_name |
| 261 | + << " ver " |
| 262 | + << server_info.version_major << "." |
| 263 | + << server_info.version_minor << "." |
| 264 | + << server_info.version_patch |
| 265 | + << " (" << server_info.revision << ")"; |
| 266 | +} |
| 267 | + |
| 268 | +} |
0 commit comments