2014-06-16 17:32:31 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Core/NamesAndTypes.h>
|
|
|
|
#include <Storages/IStorage.h>
|
2020-02-03 11:22:21 +00:00
|
|
|
#include <Processors/Sources/NullSource.h>
|
2021-07-23 19:33:59 +00:00
|
|
|
#include <Processors/Sinks/SinkToStorage.h>
|
2021-10-16 14:03:50 +00:00
|
|
|
#include <QueryPipeline/Pipe.h>
|
2014-06-16 17:32:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/** When writing, does nothing.
|
|
|
|
* When reading, returns nothing.
|
2014-06-16 17:32:31 +00:00
|
|
|
*/
|
2022-05-03 06:43:28 +00:00
|
|
|
class StorageNull final : public IStorage
|
2014-06-16 17:32:31 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-04-19 20:47:29 +00:00
|
|
|
StorageNull(
|
|
|
|
const StorageID & table_id_, ColumnsDescription columns_description_, ConstraintsDescription constraints_, const String & comment)
|
|
|
|
: IStorage(table_id_)
|
|
|
|
{
|
|
|
|
StorageInMemoryMetadata storage_metadata;
|
|
|
|
storage_metadata.setColumns(columns_description_);
|
|
|
|
storage_metadata.setConstraints(constraints_);
|
|
|
|
storage_metadata.setComment(comment);
|
|
|
|
setInMemoryMetadata(storage_metadata);
|
|
|
|
}
|
|
|
|
|
2014-10-03 17:55:36 +00:00
|
|
|
std::string getName() const override { return "Null"; }
|
2014-06-16 17:32:31 +00:00
|
|
|
|
2020-08-03 13:54:14 +00:00
|
|
|
Pipe read(
|
2018-01-09 02:09:08 +00:00
|
|
|
const Names & column_names,
|
2021-07-09 03:15:41 +00:00
|
|
|
const StorageSnapshotPtr & storage_snapshot,
|
2020-09-20 17:52:17 +00:00
|
|
|
SelectQueryInfo &,
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextPtr /*context*/,
|
2018-09-08 11:29:23 +00:00
|
|
|
QueryProcessingStage::Enum /*processing_stage*/,
|
2022-10-07 10:46:45 +00:00
|
|
|
size_t /*max_block_size*/,
|
|
|
|
size_t /*num_streams*/) override
|
2014-06-16 17:32:31 +00:00
|
|
|
{
|
2020-08-03 13:54:14 +00:00
|
|
|
return Pipe(
|
2021-07-09 03:15:41 +00:00
|
|
|
std::make_shared<NullSource>(storage_snapshot->getSampleBlockForColumns(column_names)));
|
2014-06-16 17:32:31 +00:00
|
|
|
}
|
|
|
|
|
2020-08-26 16:41:30 +00:00
|
|
|
bool supportsParallelInsert() const override { return true; }
|
|
|
|
|
2021-07-23 19:33:59 +00:00
|
|
|
SinkToStoragePtr write(const ASTPtr &, const StorageMetadataPtr & metadata_snapshot, ContextPtr) override
|
2014-06-16 17:32:31 +00:00
|
|
|
{
|
2021-07-23 19:33:59 +00:00
|
|
|
return std::make_shared<NullSinkToStorage>(metadata_snapshot->getSampleBlock());
|
2014-06-16 17:32:31 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
void checkAlterIsPossible(const AlterCommands & commands, ContextPtr context) const override;
|
2019-12-26 18:17:05 +00:00
|
|
|
|
2021-10-25 17:49:49 +00:00
|
|
|
void alter(const AlterCommands & params, ContextPtr context, AlterLockHolder & table_lock_holder) override;
|
2018-01-11 19:13:19 +00:00
|
|
|
|
2020-11-25 13:47:32 +00:00
|
|
|
std::optional<UInt64> totalRows(const Settings &) const override
|
2020-03-29 12:22:17 +00:00
|
|
|
{
|
|
|
|
return {0};
|
|
|
|
}
|
2020-11-25 13:47:32 +00:00
|
|
|
std::optional<UInt64> totalBytes(const Settings &) const override
|
2020-03-29 14:44:32 +00:00
|
|
|
{
|
|
|
|
return {0};
|
|
|
|
}
|
2020-03-29 12:22:17 +00:00
|
|
|
|
2014-06-16 17:32:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|