2013-10-30 13:52:02 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <DB/Parsers/ASTSelectQuery.h>
|
2013-11-15 09:43:50 +00:00
|
|
|
|
#include <DB/Storages/IStorage.h>
|
2013-10-30 13:52:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
2014-10-29 01:18:50 +00:00
|
|
|
|
class StorageView : public IStorage
|
|
|
|
|
{
|
2013-10-30 13:52:02 +00:00
|
|
|
|
|
|
|
|
|
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_);
|
2013-11-08 17:43:03 +00:00
|
|
|
|
|
2014-10-07 23:08:56 +00:00
|
|
|
|
std::string getName() const override { return "View"; }
|
|
|
|
|
std::string getTableName() const override { return table_name; }
|
2014-10-10 15:45:43 +00:00
|
|
|
|
const NamesAndTypesList & getColumnsListImpl() const override { return *columns; }
|
2014-10-29 01:18:50 +00:00
|
|
|
|
ASTPtr getInnerQuery() const { return inner_query.clone(); };
|
2013-11-08 17:43:03 +00:00
|
|
|
|
|
2014-10-07 23:08:56 +00:00
|
|
|
|
/// Пробрасывается внутрь запроса и решается на его уровне.
|
|
|
|
|
bool supportsSampling() const override { return true; }
|
|
|
|
|
bool supportsFinal() const override { return true; }
|
|
|
|
|
|
2015-01-16 15:22:12 +00:00
|
|
|
|
bool supportsParallelReplicas() const override { return true; }
|
|
|
|
|
|
2014-10-07 23:08:56 +00:00
|
|
|
|
BlockInputStreams read(
|
2013-11-08 17:43:03 +00:00
|
|
|
|
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
|
|
|
|
|
2014-10-07 23:08:56 +00:00
|
|
|
|
void drop() override;
|
2013-11-08 17:43:03 +00:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
String select_database_name;
|
|
|
|
|
String select_table_name;
|
|
|
|
|
String table_name;
|
|
|
|
|
String database_name;
|
2013-10-30 13:52:02 +00:00
|
|
|
|
ASTSelectQuery inner_query;
|
2013-11-08 17:43:03 +00:00
|
|
|
|
Context & context;
|
2013-10-30 13:52:02 +00:00
|
|
|
|
NamesAndTypesListPtr columns;
|
|
|
|
|
|
2014-09-30 03:08:47 +00:00
|
|
|
|
StorageView(
|
|
|
|
|
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_);
|
2013-10-30 13:52:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|