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>
|
2020-02-17 15:07:42 +00:00
|
|
|
#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,
|
2020-09-20 17:52:17 +00:00
|
|
|
SelectQueryInfo & /*query_info*/,
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextPtr /*context*/,
|
2019-07-29 16:20:17 +00:00
|
|
|
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
|
|
|
|
2020-10-07 10:11:58 +00:00
|
|
|
/// Get only required columns.
|
|
|
|
Block block;
|
|
|
|
for (const auto & name : column_names)
|
|
|
|
block.insert(res_block.getByName(name));
|
|
|
|
|
|
|
|
Chunk chunk(block.getColumns(), block.rows());
|
|
|
|
return Pipe(std::make_shared<SourceFromSingleChunk>(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
|
|
|
}
|