1#include <Interpreters/Context.h>
2#include <Storages/MergeTree/MergeList.h>
3#include <Storages/System/StorageSystemMerges.h>
4
5
6namespace DB
7{
8
9NamesAndTypesList StorageSystemMerges::getNamesAndTypes()
10{
11 return {
12 {"database", std::make_shared<DataTypeString>()},
13 {"table", std::make_shared<DataTypeString>()},
14 {"elapsed", std::make_shared<DataTypeFloat64>()},
15 {"progress", std::make_shared<DataTypeFloat64>()},
16 {"num_parts", std::make_shared<DataTypeUInt64>()},
17 {"source_part_names", std::make_shared<DataTypeArray>(std::make_shared<DataTypeString>())},
18 {"result_part_name", std::make_shared<DataTypeString>()},
19 {"source_part_paths", std::make_shared<DataTypeArray>(std::make_shared<DataTypeString>())},
20 {"result_part_path", std::make_shared<DataTypeString>()},
21 {"partition_id", std::make_shared<DataTypeString>()},
22 {"is_mutation", std::make_shared<DataTypeUInt8>()},
23 {"total_size_bytes_compressed", std::make_shared<DataTypeUInt64>()},
24 {"total_size_marks", std::make_shared<DataTypeUInt64>()},
25 {"bytes_read_uncompressed", std::make_shared<DataTypeUInt64>()},
26 {"rows_read", std::make_shared<DataTypeUInt64>()},
27 {"bytes_written_uncompressed", std::make_shared<DataTypeUInt64>()},
28 {"rows_written", std::make_shared<DataTypeUInt64>()},
29 {"columns_written", std::make_shared<DataTypeUInt64>()},
30 {"memory_usage", std::make_shared<DataTypeUInt64>()},
31 {"thread_number", std::make_shared<DataTypeUInt64>()},
32 };
33}
34
35
36void StorageSystemMerges::fillData(MutableColumns & res_columns, const Context & context, const SelectQueryInfo &) const
37{
38 for (const auto & merge : context.getMergeList().get())
39 {
40 if (context.hasDatabaseAccessRights(merge.database))
41 {
42 size_t i = 0;
43 res_columns[i++]->insert(merge.database);
44 res_columns[i++]->insert(merge.table);
45 res_columns[i++]->insert(merge.elapsed);
46 res_columns[i++]->insert(merge.progress);
47 res_columns[i++]->insert(merge.num_parts);
48 res_columns[i++]->insert(merge.source_part_names);
49 res_columns[i++]->insert(merge.result_part_name);
50 res_columns[i++]->insert(merge.source_part_paths);
51 res_columns[i++]->insert(merge.result_part_path);
52 res_columns[i++]->insert(merge.partition_id);
53 res_columns[i++]->insert(merge.is_mutation);
54 res_columns[i++]->insert(merge.total_size_bytes_compressed);
55 res_columns[i++]->insert(merge.total_size_marks);
56 res_columns[i++]->insert(merge.bytes_read_uncompressed);
57 res_columns[i++]->insert(merge.rows_read);
58 res_columns[i++]->insert(merge.bytes_written_uncompressed);
59 res_columns[i++]->insert(merge.rows_written);
60 res_columns[i++]->insert(merge.columns_written);
61 res_columns[i++]->insert(merge.memory_usage);
62 res_columns[i++]->insert(merge.thread_number);
63 }
64 }
65}
66
67}
68