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
|
|
|
|
2014-10-03 17:55:36 +00:00
|
|
|
std::string getName() const override { 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-10-03 17:55:36 +00:00
|
|
|
NameAndTypePair getColumn(const String & column_name) const override;
|
|
|
|
bool hasColumn(const String & column_name) const override;
|
2014-08-05 10:56:58 +00:00
|
|
|
|
2014-10-07 23:08:56 +00:00
|
|
|
bool supportsSampling() const override { return data->supportsSampling(); }
|
|
|
|
bool supportsFinal() const override { return data->supportsFinal(); }
|
|
|
|
bool supportsPrewhere() const override { return data->supportsPrewhere(); }
|
|
|
|
|
2014-10-03 17:55:36 +00:00
|
|
|
BlockOutputStreamPtr write(ASTPtr query) override;
|
2014-03-20 13:28:49 +00:00
|
|
|
void drop() override;
|
2014-10-03 17:55:36 +00:00
|
|
|
bool optimize() override;
|
2013-11-08 17:43:03 +00:00
|
|
|
|
|
|
|
BlockInputStreams read(
|
|
|
|
const Names & column_names,
|
|
|
|
ASTPtr query,
|
2014-12-17 11:53:17 +00:00
|
|
|
const Context & context,
|
2013-11-08 17:43:03 +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-11-08 17:43:03 +00:00
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
}
|