2013-10-30 13:52:02 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-08-16 02:55:52 +00:00
|
|
|
#include <Parsers/ASTSelectQuery.h>
|
2019-03-11 14:01:45 +00:00
|
|
|
#include <Parsers/IAST_fwd.h>
|
|
|
|
#include <Storages/IStorage.h>
|
|
|
|
|
|
|
|
#include <ext/shared_ptr_helper.h>
|
2013-10-30 13:52:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-06-06 18:36:13 +00:00
|
|
|
class StorageView : public ext::shared_ptr_helper<StorageView>, public IStorage
|
2014-10-29 01:18:50 +00:00
|
|
|
{
|
2019-08-26 19:07:29 +00:00
|
|
|
friend struct ext::shared_ptr_helper<StorageView>;
|
2013-10-30 13:52:02 +00:00
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
std::string getName() const override { return "View"; }
|
|
|
|
std::string getTableName() const override { return table_name; }
|
2019-07-09 15:40:21 +00:00
|
|
|
std::string getDatabaseName() const override { return database_name; }
|
2013-11-08 17:43:03 +00:00
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/// It is passed inside the query and solved at its level.
|
2017-04-01 07:20:54 +00:00
|
|
|
bool supportsSampling() const override { return true; }
|
2017-07-25 21:07:05 +00:00
|
|
|
bool supportsFinal() const override { return true; }
|
2014-10-07 23:08:56 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
BlockInputStreams read(
|
|
|
|
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,
|
2018-04-19 14:47:09 +00:00
|
|
|
QueryProcessingStage::Enum processed_stage,
|
2019-02-18 23:38:44 +00:00
|
|
|
size_t max_block_size,
|
2017-06-02 15:54:39 +00:00
|
|
|
unsigned num_streams) override;
|
2013-11-08 17:43:03 +00:00
|
|
|
|
2019-07-09 15:40:21 +00:00
|
|
|
void rename(const String & /*new_path_to_db*/, const String & new_database_name, const String & new_table_name) override
|
2018-03-01 04:23:32 +00:00
|
|
|
{
|
|
|
|
table_name = new_table_name;
|
2019-07-09 15:40:21 +00:00
|
|
|
database_name = new_database_name;
|
2018-03-01 04:23:32 +00:00
|
|
|
}
|
|
|
|
|
2017-07-25 21:07:05 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
String table_name;
|
2019-07-09 15:40:21 +00:00
|
|
|
String database_name;
|
2017-07-25 21:07:05 +00:00
|
|
|
ASTPtr inner_query;
|
2013-10-30 13:52:02 +00:00
|
|
|
|
2018-08-16 02:55:52 +00:00
|
|
|
void replaceTableNameWithSubquery(ASTSelectQuery * select_query, ASTPtr & subquery);
|
|
|
|
|
2017-11-04 03:20:18 +00:00
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
StorageView(
|
2019-07-09 15:40:21 +00:00
|
|
|
const String & database_name_,
|
2017-04-01 07:20:54 +00:00
|
|
|
const String & table_name_,
|
2017-09-17 18:49:43 +00:00
|
|
|
const ASTCreateQuery & query,
|
2018-03-06 20:18:34 +00:00
|
|
|
const ColumnsDescription & columns_);
|
2013-10-30 13:52:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|