2017-12-12 15:54:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <ext/shared_ptr_helper.h>
|
2018-06-10 19:22:49 +00:00
|
|
|
#include <Formats/FormatSettings.h>
|
2017-12-12 15:54:03 +00:00
|
|
|
#include <Storages/IStorage.h>
|
|
|
|
#include <Storages/MergeTree/MergeTreeData.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class Context;
|
|
|
|
|
|
|
|
|
|
|
|
/** Implements system table 'parts' which allows to get information about data parts for tables of MergeTree family.
|
|
|
|
*/
|
|
|
|
class StorageSystemPartsBase : public IStorage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::string getTableName() const override { return name; }
|
|
|
|
|
|
|
|
NameAndTypePair getColumn(const String & column_name) const override;
|
|
|
|
|
|
|
|
bool hasColumn(const String & column_name) const override;
|
|
|
|
|
|
|
|
BlockInputStreams read(
|
|
|
|
const Names & column_names,
|
|
|
|
const SelectQueryInfo & query_info,
|
|
|
|
const Context & context,
|
2018-04-19 15:18:26 +00:00
|
|
|
QueryProcessingStage::Enum processed_stage,
|
2019-02-18 23:38:44 +00:00
|
|
|
size_t max_block_size,
|
2017-12-12 15:54:03 +00:00
|
|
|
unsigned num_streams) override;
|
|
|
|
|
|
|
|
struct StoragesInfo
|
|
|
|
{
|
|
|
|
StoragePtr storage;
|
2019-03-07 18:04:47 +00:00
|
|
|
TableStructureReadLockHolder table_lock;
|
2017-12-12 15:54:03 +00:00
|
|
|
|
|
|
|
String database;
|
|
|
|
String table;
|
|
|
|
String engine;
|
|
|
|
|
|
|
|
MergeTreeData * data;
|
|
|
|
MergeTreeData::DataPartStateVector all_parts_state;
|
|
|
|
MergeTreeData::DataPartsVector all_parts;
|
|
|
|
|
|
|
|
operator bool() const { return storage != nullptr; }
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
const std::string name;
|
2018-01-25 14:42:39 +00:00
|
|
|
|
2017-12-12 15:54:03 +00:00
|
|
|
bool hasStateColumn(const Names & column_names);
|
|
|
|
|
|
|
|
protected:
|
2018-06-08 01:51:55 +00:00
|
|
|
const FormatSettings format_settings;
|
|
|
|
|
2018-01-25 14:42:39 +00:00
|
|
|
StorageSystemPartsBase(std::string name_, NamesAndTypesList && columns_);
|
2017-12-12 15:54:03 +00:00
|
|
|
|
2017-12-28 18:20:53 +00:00
|
|
|
virtual void processNextStorage(MutableColumns & columns, const StoragesInfo & info, bool has_state_column) = 0;
|
2017-12-12 15:54:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|