ClickHouse/dbms/src/Storages/StorageView.cpp

50 lines
1.3 KiB
C++
Raw Normal View History

#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>
#include <Storages/StorageView.h>
namespace DB
{
namespace ErrorCodes
{
extern const int INCORRECT_QUERY;
}
StorageView::StorageView(
const String & table_name_,
const String & database_name_,
const ASTCreateQuery & query,
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_),
database_name(database_name_), columns(columns_)
{
if (!query.select)
throw Exception("SELECT query is not specified for " + getName(), ErrorCodes::INCORRECT_QUERY);
inner_query = query.select->ptr();
}
2014-06-12 23:21:38 +00:00
BlockInputStreams StorageView::read(
const Names & column_names,
const SelectQueryInfo & query_info,
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)
{
processed_stage = QueryProcessingStage::FetchColumns;
return InterpreterSelectQuery(inner_query->clone(), context, column_names).executeWithoutUnion();
}
}