ClickHouse/src/Storages/StorageDummy.cpp

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

59 lines
1.7 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
{
StorageDummy::StorageDummy(const StorageID & table_id_, const ColumnsDescription & columns_, ColumnsDescription object_columns_)
2023-02-24 12:46:09 +00:00
: IStorage(table_id_)
, object_columns(std::move(object_columns_))
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,
SelectQueryInfo &,
ContextPtr,
QueryProcessingStage::Enum,
size_t,
size_t)
{
query_plan.addStep(std::make_unique<ReadFromDummy>(*this, storage_snapshot, column_names));
}
ReadFromDummy::ReadFromDummy(const StorageDummy & storage_,
StorageSnapshotPtr storage_snapshot_,
Names column_names_)
: SourceStepWithFilter(DataStream{.header = storage_snapshot_->getSampleBlockForColumns(column_names_)})
, storage(storage_)
, storage_snapshot(std::move(storage_snapshot_))
, column_names(std::move(column_names_))
{}
void ReadFromDummy::initializePipeline(QueryPipelineBuilder & pipeline, const BuildQueryPipelineSettings &)
{
Pipe pipe(std::make_shared<SourceFromSingleChunk>(getOutputStream().header));
pipeline.init(std::move(pipe));
}
}