2013-11-08 17:43:03 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/Storages/StorageView.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class StorageMaterializedView : public StorageView {
|
|
|
|
|
|
|
|
public:
|
2014-09-30 03:08:47 +00:00
|
|
|
static StoragePtr create(
|
|
|
|
const String & table_name_,
|
|
|
|
const String & database_name_,
|
|
|
|
Context & context_,
|
|
|
|
ASTPtr & query_,
|
|
|
|
NamesAndTypesListPtr columns_,
|
2014-10-03 15:30:10 +00:00
|
|
|
const NamesAndTypesList & materialized_columns_,
|
2014-09-30 03:08:47 +00:00
|
|
|
const NamesAndTypesList & alias_columns_,
|
|
|
|
const ColumnDefaults & column_defaults_,
|
|
|
|
bool attach_);
|
2013-11-08 17:43:03 +00:00
|
|
|
|
|
|
|
std::string getName() const { return "MaterializedView"; }
|
2013-11-13 14:39:48 +00:00
|
|
|
std::string getInnerTableName() const { return ".inner." + table_name; }
|
2013-11-08 17:43:03 +00:00
|
|
|
|
2014-08-05 10:56:58 +00:00
|
|
|
NameAndTypePair getColumn(const String &column_name) const;
|
|
|
|
bool hasColumn(const String &column_name) const;
|
|
|
|
|
2013-11-08 17:43:03 +00:00
|
|
|
BlockOutputStreamPtr write(ASTPtr query);
|
2014-03-20 13:28:49 +00:00
|
|
|
void drop() override;
|
2013-11-08 17:43:03 +00:00
|
|
|
bool optimize();
|
|
|
|
|
|
|
|
BlockInputStreams read(
|
|
|
|
const Names & column_names,
|
|
|
|
ASTPtr query,
|
|
|
|
const Settings & settings,
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
size_t max_block_size = DEFAULT_BLOCK_SIZE,
|
|
|
|
unsigned threads = 1);
|
|
|
|
|
|
|
|
private:
|
|
|
|
StoragePtr data;
|
|
|
|
|
2014-09-30 03:08:47 +00:00
|
|
|
StorageMaterializedView(
|
|
|
|
const String & table_name_,
|
|
|
|
const String & database_name_,
|
|
|
|
Context & context_,
|
|
|
|
ASTPtr & query_,
|
|
|
|
NamesAndTypesListPtr columns_,
|
2014-10-03 15:30:10 +00:00
|
|
|
const NamesAndTypesList & materialized_columns_,
|
2014-09-30 03:08:47 +00:00
|
|
|
const NamesAndTypesList & alias_columns_,
|
|
|
|
const ColumnDefaults & column_defaults_,
|
|
|
|
bool attach_);
|
2013-11-08 17:43:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|