ClickHouse/src/Storages/StorageValues.cpp

40 lines
1.1 KiB
C++
Raw Normal View History

2019-07-29 13:50:13 +00:00
#include <Storages/IStorage.h>
2019-08-01 01:53:38 +00:00
#include <Storages/ColumnsDescription.h>
2019-07-29 13:50:13 +00:00
#include <Storages/StorageValues.h>
#include <DataStreams/OneBlockInputStream.h>
#include <Processors/Sources/SourceFromSingleChunk.h>
#include <Processors/Pipe.h>
2019-07-29 13:50:13 +00:00
2019-07-30 12:15:02 +00:00
2019-07-29 13:50:13 +00:00
namespace DB
{
2019-07-31 14:12:05 +00:00
2020-04-29 12:15:23 +00:00
StorageValues::StorageValues(
const StorageID & table_id_,
const ColumnsDescription & columns_,
const Block & res_block_,
const NamesAndTypesList & virtuals_)
: IStorage(table_id_), res_block(res_block_), virtuals(virtuals_)
2019-07-30 22:06:48 +00:00
{
2020-06-19 15:39:41 +00:00
StorageInMemoryMetadata storage_metadata;
storage_metadata.setColumns(columns_);
setInMemoryMetadata(storage_metadata);
2019-07-30 22:06:48 +00:00
}
2019-07-29 13:50:13 +00:00
2020-08-03 13:54:14 +00:00
Pipe StorageValues::read(
2019-07-29 16:20:17 +00:00
const Names & column_names,
2020-06-17 14:32:25 +00:00
const StorageMetadataPtr & metadata_snapshot,
2019-07-29 16:20:17 +00:00
const SelectQueryInfo & /*query_info*/,
const Context & /*context*/,
QueryProcessingStage::Enum /*processed_stage*/,
size_t /*max_block_size*/,
unsigned /*num_streams*/)
2019-07-29 13:50:13 +00:00
{
2020-06-19 17:17:13 +00:00
metadata_snapshot->check(column_names, getVirtuals(), getStorageID());
2019-07-29 13:50:13 +00:00
Chunk chunk(res_block.getColumns(), res_block.rows());
2020-08-03 13:54:14 +00:00
return Pipe(std::make_shared<SourceFromSingleChunk>(res_block.cloneEmpty(), std::move(chunk)));
2019-07-29 13:50:13 +00:00
}
2019-07-30 12:15:02 +00:00
2019-07-29 16:20:17 +00:00
}