| 46 | using namespace Statistics::AutoStats; |
| 47 | |
| 48 | static Block constructInfoBlock( |
| 49 | ContextPtr context, const String & table_name, UInt64 column_count, String row_count_or_error, double time, bool only_header = false) |
| 50 | { |
| 51 | Block block; |
| 52 | auto append_str_column = [&](String header, String value) { |
| 53 | ColumnWithTypeAndName tuple; |
| 54 | tuple.name = header; |
| 55 | tuple.type = std::make_shared<DataTypeString>(); |
| 56 | auto col = tuple.type->createColumn(); |
| 57 | if (!only_header) |
| 58 | { |
| 59 | col->insertData(value.data(), value.size()); |
| 60 | } |
| 61 | tuple.column = std::move(col); |
| 62 | block.insert(std::move(tuple)); |
| 63 | }; |
| 64 | |
| 65 | auto append_num_column = [&]<typename T>(String header, T value) { |
| 66 | static_assert(std::is_trivial_v<T>); |
| 67 | ColumnWithTypeAndName tuple; |
| 68 | tuple.name = header; |
| 69 | tuple.type = std::make_shared<DataTypeNumber<T>>(); |
| 70 | auto col = ColumnVector<T>::create(); |
| 71 | if (!only_header) |
| 72 | { |
| 73 | col->insertValue(value); |
| 74 | } |
| 75 | tuple.column = std::move(col); |
| 76 | block.insert(std::move(tuple)); |
| 77 | }; |
| 78 | |
| 79 | append_str_column("table_name", table_name); |
| 80 | append_num_column("column_count", column_count); |
| 81 | append_str_column("row_count_or_error", row_count_or_error); |
| 82 | if (context->getSettingsRef().create_stats_time_output) |
| 83 | { |
| 84 | append_num_column("elapsed_time", time); |
| 85 | } |
| 86 | return block; |
| 87 | } |
| 88 | |
| 89 | |
| 90 | namespace |
no test coverage detected