diff --git a/dbms/include/DB/Storages/StorageCloud.h b/dbms/include/DB/Storages/StorageCloud.h new file mode 100644 index 00000000000..08fdffe7a33 --- /dev/null +++ b/dbms/include/DB/Storages/StorageCloud.h @@ -0,0 +1,71 @@ +#pragma once + +#include +#include + + +namespace DB +{ + +class DatabaseCloud; + + +/** Таблица, представляющая собой объединение произвольного количества других таблиц. + * У всех таблиц должна быть одинаковая структура. + */ +class StorageCloud : public IStorage +{ +public: + static StoragePtr create( + const std::string & name_, + NamesAndTypesListPtr columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, + const ColumnDefaults & column_defaults_); + + std::string getName() const override { return "Cloud"; } + std::string getTableName() const override { return name; } + + /// Проверка откладывается до метода read. Там проверяется поддержка PREWHERE у использующихся таблиц. + bool supportsSampling() const override { return true; } + bool supportsPrewhere() const override { return true; } + bool supportsFinal() const override { return true; } + bool supportsIndexForIn() const override { return true; } + + const NamesAndTypesList & getColumnsListImpl() const override { return *columns; } + NameAndTypePair getColumn(const String & column_name) const override; + bool hasColumn(const String & column_name) const override; + + BlockInputStreams read( + const Names & column_names, + ASTPtr query, + const Context & context, + const Settings & settings, + QueryProcessingStage::Enum & processed_stage, + size_t max_block_size = DEFAULT_BLOCK_SIZE, + unsigned threads = 1) override; + + void drop() override {} + + void rename(const String & new_path_to_db, const String & new_database_name, const String & new_table_name) override + { + name = new_table_name; + } + + //void alter(const AlterCommands & params, const String & database_name, const String & table_name, const Context & context) override; + +private: + String name; + NamesAndTypesListPtr columns; + + std::weak_ptr database; + + StorageCloud( + const std::string & name_, + NamesAndTypesListPtr columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, + const ColumnDefaults & column_defaults_); +}; + +} diff --git a/dbms/src/Storages/StorageCloud.cpp b/dbms/src/Storages/StorageCloud.cpp new file mode 100644 index 00000000000..50b4c3ede5f --- /dev/null +++ b/dbms/src/Storages/StorageCloud.cpp @@ -0,0 +1,25 @@ +#include +#include + + +namespace DB +{ + +namespace ErrorCodes +{ + extern const int LOGICAL_ERROR; +} + + +void StorageCloud::drop() +{ + DatabasePtr owned_db = database.lock(); + if (!owned_db) + throw Exception("DatabaseCloud is detached", ErrorCodes::LOGICAL_ERROR); + + DatabaseCloud & db = static_cast(*owned_db); + + +} + +}