2017-04-01 09:19:00 +00:00
|
|
|
#include <Interpreters/InterpreterSelectQuery.h>
|
|
|
|
#include <Parsers/ASTIdentifier.h>
|
|
|
|
#include <Parsers/ASTCreateQuery.h>
|
|
|
|
#include <Parsers/ASTSelectQuery.h>
|
2017-07-13 20:58:19 +00:00
|
|
|
#include <Common/typeid_cast.h>
|
2013-11-08 17:43:03 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Storages/StorageView.h>
|
2013-11-08 17:43:03 +00:00
|
|
|
|
2013-10-30 13:52:02 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-01-11 21:46:36 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
2017-09-19 19:18:34 +00:00
|
|
|
extern const int INCORRECT_QUERY;
|
2016-01-11 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
2013-10-30 13:52:02 +00:00
|
|
|
|
2014-09-30 03:08:47 +00:00
|
|
|
StorageView::StorageView(
|
2017-04-01 07:20:54 +00:00
|
|
|
const String & table_name_,
|
|
|
|
const String & database_name_,
|
2017-09-17 18:49:43 +00:00
|
|
|
const ASTCreateQuery & query,
|
2017-04-01 07:20:54 +00:00
|
|
|
NamesAndTypesListPtr columns_,
|
|
|
|
const NamesAndTypesList & materialized_columns_,
|
|
|
|
const NamesAndTypesList & alias_columns_,
|
|
|
|
const ColumnDefaults & column_defaults_)
|
|
|
|
: IStorage{materialized_columns_, alias_columns_, column_defaults_}, table_name(table_name_),
|
2017-11-04 03:20:18 +00:00
|
|
|
database_name(database_name_), columns(columns_)
|
2013-11-08 17:43:03 +00:00
|
|
|
{
|
2017-09-19 19:18:34 +00:00
|
|
|
if (!query.select)
|
|
|
|
throw Exception("SELECT query is not specified for " + getName(), ErrorCodes::INCORRECT_QUERY);
|
|
|
|
|
2017-09-17 18:49:43 +00:00
|
|
|
inner_query = query.select->ptr();
|
2013-11-08 17:43:03 +00:00
|
|
|
}
|
|
|
|
|
2014-06-12 23:21:38 +00:00
|
|
|
|
2013-11-08 17:43:03 +00:00
|
|
|
BlockInputStreams StorageView::read(
|
2017-04-01 07:20:54 +00:00
|
|
|
const Names & column_names,
|
2017-07-15 03:48:36 +00:00
|
|
|
const SelectQueryInfo & query_info,
|
2017-04-01 07:20:54 +00:00
|
|
|
const Context & context,
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
const size_t max_block_size,
|
2017-06-02 15:54:39 +00:00
|
|
|
const unsigned num_streams)
|
2013-10-30 13:52:02 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
processed_stage = QueryProcessingStage::FetchColumns;
|
2017-07-25 21:07:05 +00:00
|
|
|
return InterpreterSelectQuery(inner_query->clone(), context, column_names).executeWithoutUnion();
|
2013-11-08 17:43:03 +00:00
|
|
|
}
|
|
|
|
|
2013-10-30 13:52:02 +00:00
|
|
|
}
|