2017-04-01 09:19:00 +00:00
|
|
|
#include <Interpreters/Context.h>
|
|
|
|
#include <Storages/MergeTree/MergeList.h>
|
2018-07-24 14:28:56 +00:00
|
|
|
#include <Storages/System/StorageSystemMerges.h>
|
2020-03-07 17:37:38 +00:00
|
|
|
#include <Access/ContextAccess.h>
|
2015-04-16 06:12:35 +00:00
|
|
|
|
2014-09-10 11:34:26 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2018-07-24 14:28:56 +00:00
|
|
|
NamesAndTypesList StorageSystemMerges::getNamesAndTypes()
|
2018-01-25 14:42:39 +00:00
|
|
|
{
|
2018-07-24 14:28:56 +00:00
|
|
|
return {
|
|
|
|
{"database", std::make_shared<DataTypeString>()},
|
|
|
|
{"table", std::make_shared<DataTypeString>()},
|
|
|
|
{"elapsed", std::make_shared<DataTypeFloat64>()},
|
|
|
|
{"progress", std::make_shared<DataTypeFloat64>()},
|
|
|
|
{"num_parts", std::make_shared<DataTypeUInt64>()},
|
|
|
|
{"source_part_names", std::make_shared<DataTypeArray>(std::make_shared<DataTypeString>())},
|
|
|
|
{"result_part_name", std::make_shared<DataTypeString>()},
|
2019-11-20 08:51:52 +00:00
|
|
|
{"source_part_paths", std::make_shared<DataTypeArray>(std::make_shared<DataTypeString>())},
|
|
|
|
{"result_part_path", std::make_shared<DataTypeString>()},
|
2018-09-11 11:16:40 +00:00
|
|
|
{"partition_id", std::make_shared<DataTypeString>()},
|
2019-01-13 22:02:33 +00:00
|
|
|
{"is_mutation", std::make_shared<DataTypeUInt8>()},
|
2018-07-24 14:28:56 +00:00
|
|
|
{"total_size_bytes_compressed", std::make_shared<DataTypeUInt64>()},
|
|
|
|
{"total_size_marks", std::make_shared<DataTypeUInt64>()},
|
|
|
|
{"bytes_read_uncompressed", std::make_shared<DataTypeUInt64>()},
|
|
|
|
{"rows_read", std::make_shared<DataTypeUInt64>()},
|
|
|
|
{"bytes_written_uncompressed", std::make_shared<DataTypeUInt64>()},
|
|
|
|
{"rows_written", std::make_shared<DataTypeUInt64>()},
|
|
|
|
{"columns_written", std::make_shared<DataTypeUInt64>()},
|
|
|
|
{"memory_usage", std::make_shared<DataTypeUInt64>()},
|
2020-02-02 20:01:13 +00:00
|
|
|
{"thread_id", std::make_shared<DataTypeUInt64>()},
|
2020-09-03 13:00:13 +00:00
|
|
|
{"merge_type", std::make_shared<DataTypeString>()},
|
2018-07-24 14:28:56 +00:00
|
|
|
};
|
2014-09-10 11:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-24 14:28:56 +00:00
|
|
|
void StorageSystemMerges::fillData(MutableColumns & res_columns, const Context & context, const SelectQueryInfo &) const
|
2014-09-10 11:34:26 +00:00
|
|
|
{
|
2020-03-07 17:37:38 +00:00
|
|
|
const auto access = context.getAccess();
|
|
|
|
const bool check_access_for_tables = !access->isGranted(AccessType::SHOW_TABLES);
|
2020-01-24 16:20:36 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
for (const auto & merge : context.getMergeList().get())
|
|
|
|
{
|
2020-03-07 17:37:38 +00:00
|
|
|
if (check_access_for_tables && !access->isGranted(AccessType::SHOW_TABLES, merge.database, merge.table))
|
2020-01-24 16:20:36 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
size_t i = 0;
|
|
|
|
res_columns[i++]->insert(merge.database);
|
|
|
|
res_columns[i++]->insert(merge.table);
|
|
|
|
res_columns[i++]->insert(merge.elapsed);
|
|
|
|
res_columns[i++]->insert(merge.progress);
|
|
|
|
res_columns[i++]->insert(merge.num_parts);
|
|
|
|
res_columns[i++]->insert(merge.source_part_names);
|
|
|
|
res_columns[i++]->insert(merge.result_part_name);
|
|
|
|
res_columns[i++]->insert(merge.source_part_paths);
|
|
|
|
res_columns[i++]->insert(merge.result_part_path);
|
|
|
|
res_columns[i++]->insert(merge.partition_id);
|
|
|
|
res_columns[i++]->insert(merge.is_mutation);
|
|
|
|
res_columns[i++]->insert(merge.total_size_bytes_compressed);
|
|
|
|
res_columns[i++]->insert(merge.total_size_marks);
|
|
|
|
res_columns[i++]->insert(merge.bytes_read_uncompressed);
|
|
|
|
res_columns[i++]->insert(merge.rows_read);
|
|
|
|
res_columns[i++]->insert(merge.bytes_written_uncompressed);
|
|
|
|
res_columns[i++]->insert(merge.rows_written);
|
|
|
|
res_columns[i++]->insert(merge.columns_written);
|
|
|
|
res_columns[i++]->insert(merge.memory_usage);
|
2020-02-02 02:27:15 +00:00
|
|
|
res_columns[i++]->insert(merge.thread_id);
|
2020-09-03 13:00:13 +00:00
|
|
|
if (!merge.is_mutation)
|
|
|
|
res_columns[i++]->insert(merge.merge_type);
|
|
|
|
else
|
|
|
|
res_columns[i++]->insertDefault();
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2014-09-10 11:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|