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; }
|
2016-03-22 21:26:13 +00:00
|
|
|
StoragePtr getInnerTable() const { return context.getTable(database_name, getInnerTableName()); }
|
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
|
|
|
|
2016-03-22 21:26:13 +00:00
|
|
|
bool supportsSampling() const override { return getInnerTable()->supportsSampling(); }
|
|
|
|
bool supportsPrewhere() const override { return getInnerTable()->supportsPrewhere(); }
|
|
|
|
bool supportsFinal() const override { return getInnerTable()->supportsFinal(); }
|
|
|
|
bool supportsParallelReplicas() const override { return getInnerTable()->supportsParallelReplicas(); }
|
2016-05-16 18:43:38 +00:00
|
|
|
bool supportsIndexForIn() const override { return getInnerTable()->supportsIndexForIn(); }
|
2014-10-07 23:08:56 +00:00
|
|
|
|
2015-09-10 20:43:42 +00:00
|
|
|
BlockOutputStreamPtr write(ASTPtr query, const Settings & settings) override;
|
2014-03-20 13:28:49 +00:00
|
|
|
void drop() override;
|
2016-05-16 18:43:38 +00:00
|
|
|
bool optimize(const String & partition, bool final, const Settings & settings) 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:
|
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
|
|
|
};
|
|
|
|
|
|
|
|
}
|