2013-02-07 13:40:59 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <DB/Storages/StorageChunks.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
2014-09-30 03:08:47 +00:00
|
|
|
|
|
2013-02-07 13:40:59 +00:00
|
|
|
|
/** Ссылка на кусок данных в таблице типа Chunks.
|
|
|
|
|
* Запись не поддерживается.
|
|
|
|
|
*/
|
|
|
|
|
class StorageChunkRef : public IStorage
|
|
|
|
|
{
|
|
|
|
|
public:
|
2013-06-15 03:33:45 +00:00
|
|
|
|
static StoragePtr create(const std::string & name_, const Context & context_, const std::string & source_database_name_, const std::string & source_table_name_, bool attach);
|
2014-09-30 03:08:47 +00:00
|
|
|
|
|
2014-10-03 17:55:36 +00:00
|
|
|
|
std::string getName() const override { return "ChunkRef"; }
|
|
|
|
|
std::string getTableName() const override { return name; }
|
2014-09-30 03:08:47 +00:00
|
|
|
|
|
2015-07-15 20:40:19 +00:00
|
|
|
|
const NamesAndTypesList & getColumnsListImpl() const override { return typeid_cast<const StorageChunks &>(*getSource()).getColumnsListImpl(); }
|
2014-01-17 15:19:20 +00:00
|
|
|
|
/// В таблице, на которую мы ссылаемся, могут быть виртуальные столбцы.
|
2015-07-15 20:40:19 +00:00
|
|
|
|
NameAndTypePair getColumn(const String & column_name) const override { return getSource()->getColumn(column_name); };
|
|
|
|
|
bool hasColumn(const String & column_name) const override { return getSource()->hasColumn(column_name); };
|
2014-01-17 15:19:20 +00:00
|
|
|
|
|
2013-02-07 13:40:59 +00:00
|
|
|
|
BlockInputStreams read(
|
|
|
|
|
const Names & column_names,
|
|
|
|
|
ASTPtr query,
|
2014-12-17 11:53:17 +00:00
|
|
|
|
const Context & context,
|
2013-02-07 13:40:59 +00:00
|
|
|
|
const Settings & settings,
|
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
|
size_t max_block_size = DEFAULT_BLOCK_SIZE,
|
2014-10-03 17:55:36 +00:00
|
|
|
|
unsigned threads = 1) override;
|
2013-06-17 07:01:31 +00:00
|
|
|
|
|
2015-01-21 03:56:28 +00:00
|
|
|
|
ASTPtr getCustomCreateQuery(const Context & context) const override;
|
2014-09-30 03:08:47 +00:00
|
|
|
|
|
2014-03-20 13:28:49 +00:00
|
|
|
|
void drop() override;
|
2014-09-30 03:08:47 +00:00
|
|
|
|
|
2013-02-08 17:06:29 +00:00
|
|
|
|
String source_database_name;
|
|
|
|
|
String source_table_name;
|
2014-08-04 11:21:13 +00:00
|
|
|
|
|
|
|
|
|
bool checkData() const override;
|
2014-09-30 03:08:47 +00:00
|
|
|
|
|
2013-02-07 13:40:59 +00:00
|
|
|
|
private:
|
|
|
|
|
String name;
|
2013-05-05 18:02:05 +00:00
|
|
|
|
const Context & context;
|
2014-09-30 03:08:47 +00:00
|
|
|
|
|
2013-06-15 03:33:45 +00:00
|
|
|
|
StorageChunkRef(const std::string & name_, const Context & context_, const std::string & source_database_name_, const std::string & source_table_name_, bool attach);
|
|
|
|
|
|
|
|
|
|
/// TODO: может быть, можно просто хранить указатель на родительскую таблицу?
|
2015-07-15 20:40:19 +00:00
|
|
|
|
StoragePtr getSource();
|
|
|
|
|
const StoragePtr getSource() const;
|
2013-02-07 13:40:59 +00:00
|
|
|
|
};
|
2014-09-30 03:08:47 +00:00
|
|
|
|
|
2013-02-07 13:40:59 +00:00
|
|
|
|
}
|