mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-14 18:32:29 +00:00
495c6e03aa
* Replace all Context references with std::weak_ptr * Fix shared context captured by value * Fix build * Fix Context with named sessions * Fix copy context * Fix gcc build * Merge with master and fix build * Fix gcc-9 build
59 lines
1.8 KiB
C++
59 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <Parsers/ASTSelectQuery.h>
|
|
#include <Parsers/IAST_fwd.h>
|
|
#include <Storages/IStorage.h>
|
|
|
|
#include <ext/shared_ptr_helper.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class StorageView final : public ext::shared_ptr_helper<StorageView>, public IStorage
|
|
{
|
|
friend struct ext::shared_ptr_helper<StorageView>;
|
|
public:
|
|
std::string getName() const override { return "View"; }
|
|
bool isView() const override { return true; }
|
|
|
|
/// It is passed inside the query and solved at its level.
|
|
bool supportsSampling() const override { return true; }
|
|
bool supportsFinal() const override { return true; }
|
|
|
|
Pipe read(
|
|
const Names & column_names,
|
|
const StorageMetadataPtr & /*metadata_snapshot*/,
|
|
SelectQueryInfo & query_info,
|
|
ContextPtr context,
|
|
QueryProcessingStage::Enum processed_stage,
|
|
size_t max_block_size,
|
|
unsigned num_streams) override;
|
|
|
|
void read(
|
|
QueryPlan & query_plan,
|
|
const Names & column_names,
|
|
const StorageMetadataPtr & metadata_snapshot,
|
|
SelectQueryInfo & query_info,
|
|
ContextPtr context,
|
|
QueryProcessingStage::Enum processed_stage,
|
|
size_t max_block_size,
|
|
unsigned num_streams) override;
|
|
|
|
void replaceWithSubquery(ASTSelectQuery & select_query, ASTPtr & view_name, const StorageMetadataPtr & metadata_snapshot) const
|
|
{
|
|
replaceWithSubquery(select_query, metadata_snapshot->getSelectQuery().inner_query->clone(), view_name);
|
|
}
|
|
|
|
static void replaceWithSubquery(ASTSelectQuery & outer_query, ASTPtr view_query, ASTPtr & view_name);
|
|
static ASTPtr restoreViewName(ASTSelectQuery & select_query, const ASTPtr & view_name);
|
|
|
|
protected:
|
|
StorageView(
|
|
const StorageID & table_id_,
|
|
const ASTCreateQuery & query,
|
|
const ColumnsDescription & columns_);
|
|
};
|
|
|
|
}
|