ClickHouse/src/Storages/StorageDummy.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
1.9 KiB
C++
Raw Normal View History

2023-02-24 12:46:09 +00:00
#include <Storages/StorageDummy.h>
#include <QueryPipeline/Pipe.h>
#include <QueryPipeline/QueryPipelineBuilder.h>
#include <Processors/Chunk.h>
#include <Processors/Sources/SourceFromSingleChunk.h>
2023-06-16 19:38:50 +00:00
#include <Processors/QueryPlan/QueryPlan.h>
2023-02-24 12:46:09 +00:00
namespace DB
{
2024-02-20 09:34:10 +00:00
StorageDummy::StorageDummy(const StorageID & table_id_, const ColumnsDescription & columns_, StorageRawPtr original_storage_)
: IStorage(table_id_), original_storage(original_storage_)
2023-02-24 12:46:09 +00:00
{
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
setInMemoryMetadata(storage_metadata);
}
QueryProcessingStage::Enum StorageDummy::getQueryProcessingStage(
ContextPtr,
QueryProcessingStage::Enum,
const StorageSnapshotPtr &,
SelectQueryInfo &) const
{
return QueryProcessingStage::FetchColumns;
}
void StorageDummy::read(QueryPlan & query_plan,
const Names & column_names,
const StorageSnapshotPtr & storage_snapshot,
2024-02-20 09:34:10 +00:00
SelectQueryInfo & query_info,
ContextPtr local_context,
2023-02-24 12:46:09 +00:00
QueryProcessingStage::Enum,
size_t,
size_t)
{
2024-02-20 09:34:10 +00:00
query_plan.addStep(std::make_unique<ReadFromDummy>(
column_names,
query_info,
storage_snapshot,
local_context,
*this));
2023-02-24 12:46:09 +00:00
}
2024-02-20 09:34:10 +00:00
ReadFromDummy::ReadFromDummy(
const Names & column_names_,
const SelectQueryInfo & query_info_,
const StorageSnapshotPtr & storage_snapshot_,
const ContextPtr & context_,
const StorageDummy & storage_)
: SourceStepWithFilter(
DataStream{.header = storage_snapshot_->getSampleBlockForColumns(column_names_)},
column_names_,
query_info_,
storage_snapshot_,
context_)
2023-02-24 12:46:09 +00:00
, storage(storage_)
2024-02-20 09:34:10 +00:00
, column_names(column_names_)
{
}
2023-02-24 12:46:09 +00:00
void ReadFromDummy::initializePipeline(QueryPipelineBuilder & pipeline, const BuildQueryPipelineSettings &)
{
Pipe pipe(std::make_shared<SourceFromSingleChunk>(getOutputStream().header));
pipeline.init(std::move(pipe));
}
}