| 1 | #pragma once |
| 2 | |
| 3 | #include <Storages/IStorage.h> |
| 4 | |
| 5 | namespace DB |
| 6 | { |
| 7 | |
| 8 | class ProxyStorage : public IStorage |
| 9 | { |
| 10 | public: |
| 11 | ProxyStorage(StoragePtr storage_, BlockInputStreams streams_, QueryProcessingStage::Enum to_stage_) |
| 12 | : storage(std::move(storage_)), streams(std::move(streams_)), to_stage(to_stage_) {} |
| 13 | |
| 14 | public: |
| 15 | std::string getName() const override { return "ProxyStorage(" + storage->getName() + ")" ; } |
| 16 | std::string getTableName() const override { return storage->getTableName(); } |
| 17 | |
| 18 | bool isRemote() const override { return storage->isRemote(); } |
| 19 | bool supportsSampling() const override { return storage->supportsSampling(); } |
| 20 | bool supportsFinal() const override { return storage->supportsFinal(); } |
| 21 | bool supportsPrewhere() const override { return storage->supportsPrewhere(); } |
| 22 | bool supportsReplication() const override { return storage->supportsReplication(); } |
| 23 | bool supportsDeduplication() const override { return storage->supportsDeduplication(); } |
| 24 | |
| 25 | QueryProcessingStage::Enum getQueryProcessingStage(const Context & /*context*/) const override { return to_stage; } |
| 26 | |
| 27 | BlockInputStreams read( |
| 28 | const Names & /*column_names*/, |
| 29 | const SelectQueryInfo & /*query_info*/, |
| 30 | const Context & /*context*/, |
| 31 | QueryProcessingStage::Enum /*processed_stage*/, |
| 32 | size_t /*max_block_size*/, |
| 33 | unsigned /*num_streams*/) override |
| 34 | { |
| 35 | return streams; |
| 36 | } |
| 37 | |
| 38 | bool supportsIndexForIn() const override { return storage->supportsIndexForIn(); } |
| 39 | bool mayBenefitFromIndexForIn(const ASTPtr & left_in_operand, const Context & query_context) const override { return storage->mayBenefitFromIndexForIn(left_in_operand, query_context); } |
| 40 | ASTPtr getPartitionKeyAST() const override { return storage->getPartitionKeyAST(); } |
| 41 | ASTPtr getSortingKeyAST() const override { return storage->getSortingKeyAST(); } |
| 42 | ASTPtr getPrimaryKeyAST() const override { return storage->getPrimaryKeyAST(); } |
| 43 | ASTPtr getSamplingKeyAST() const override { return storage->getSamplingKeyAST(); } |
| 44 | Names getColumnsRequiredForPartitionKey() const override { return storage->getColumnsRequiredForPartitionKey(); } |
| 45 | Names getColumnsRequiredForSortingKey() const override { return storage->getColumnsRequiredForSortingKey(); } |
| 46 | Names getColumnsRequiredForPrimaryKey() const override { return storage->getColumnsRequiredForPrimaryKey(); } |
| 47 | Names getColumnsRequiredForSampling() const override { return storage->getColumnsRequiredForSampling(); } |
| 48 | Names getColumnsRequiredForFinal() const override { return storage->getColumnsRequiredForFinal(); } |
| 49 | |
| 50 | const ColumnsDescription & getColumns() const override { return storage->getColumns(); } |
| 51 | void setColumns(ColumnsDescription columns_) override { return storage->setColumns(columns_); } |
| 52 | NameAndTypePair getColumn(const String & column_name) const override { return storage->getColumn(column_name); } |
| 53 | bool hasColumn(const String & column_name) const override { return storage->hasColumn(column_name); } |
| 54 | static StoragePtr createProxyStorage(StoragePtr storage, BlockInputStreams streams, QueryProcessingStage::Enum to_stage) |
| 55 | { |
| 56 | return std::make_shared<ProxyStorage>(std::move(storage), std::move(streams), to_stage); |
| 57 | } |
| 58 | private: |
| 59 | StoragePtr storage; |
| 60 | BlockInputStreams streams; |
| 61 | QueryProcessingStage::Enum to_stage; |
| 62 | }; |
| 63 | |
| 64 | |
| 65 | |
| 66 | } |
| 67 | |