mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 10:52:30 +00:00
4e76629aaf
- lots of static_cast - add safe_cast - types adjustments - config - IStorage::read/watch - ... - some TODO's (to convert types in future) P.S. That was quite a journey... v2: fixes after rebase v3: fix conflicts after #42308 merged Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
68 lines
1.9 KiB
C++
68 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <Core/NamesAndTypes.h>
|
|
#include <Storages/IStorage.h>
|
|
#include <Processors/Sources/NullSource.h>
|
|
#include <Processors/Sinks/SinkToStorage.h>
|
|
#include <QueryPipeline/Pipe.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/** When writing, does nothing.
|
|
* When reading, returns nothing.
|
|
*/
|
|
class StorageNull final : public IStorage
|
|
{
|
|
public:
|
|
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);
|
|
}
|
|
|
|
std::string getName() const override { return "Null"; }
|
|
|
|
Pipe read(
|
|
const Names & column_names,
|
|
const StorageSnapshotPtr & storage_snapshot,
|
|
SelectQueryInfo &,
|
|
ContextPtr /*context*/,
|
|
QueryProcessingStage::Enum /*processing_stage*/,
|
|
size_t /*max_block_size*/,
|
|
size_t /*num_streams*/) override
|
|
{
|
|
return Pipe(
|
|
std::make_shared<NullSource>(storage_snapshot->getSampleBlockForColumns(column_names)));
|
|
}
|
|
|
|
bool supportsParallelInsert() const override { return true; }
|
|
|
|
SinkToStoragePtr write(const ASTPtr &, const StorageMetadataPtr & metadata_snapshot, ContextPtr) override
|
|
{
|
|
return std::make_shared<NullSinkToStorage>(metadata_snapshot->getSampleBlock());
|
|
}
|
|
|
|
void checkAlterIsPossible(const AlterCommands & commands, ContextPtr context) const override;
|
|
|
|
void alter(const AlterCommands & params, ContextPtr context, AlterLockHolder & table_lock_holder) override;
|
|
|
|
std::optional<UInt64> totalRows(const Settings &) const override
|
|
{
|
|
return {0};
|
|
}
|
|
std::optional<UInt64> totalBytes(const Settings &) const override
|
|
{
|
|
return {0};
|
|
}
|
|
|
|
};
|
|
|
|
}
|