2023-02-24 12:46:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Processors/QueryPlan/SourceStepWithFilter.h>
|
|
|
|
|
|
|
|
#include <Storages/SelectQueryInfo.h>
|
|
|
|
#include <Storages/IStorage.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2023-08-24 10:32:56 +00:00
|
|
|
class StorageDummy final : public IStorage
|
2023-02-24 12:46:09 +00:00
|
|
|
{
|
|
|
|
public:
|
2024-02-20 15:38:05 +00:00
|
|
|
StorageDummy(
|
|
|
|
const StorageID & table_id_, const ColumnsDescription & columns_, const StorageSnapshotPtr & original_storage_snapshot_ = nullptr);
|
2023-02-24 12:46:09 +00:00
|
|
|
|
|
|
|
std::string getName() const override { return "StorageDummy"; }
|
|
|
|
|
|
|
|
bool supportsSampling() const override { return true; }
|
|
|
|
bool supportsFinal() const override { return true; }
|
|
|
|
bool supportsPrewhere() const override { return true; }
|
|
|
|
bool supportsSubcolumns() const override { return true; }
|
|
|
|
bool supportsDynamicSubcolumns() const override { return true; }
|
2024-02-20 15:38:05 +00:00
|
|
|
bool canMoveConditionsToPrewhere() const override
|
|
|
|
{
|
|
|
|
return original_storage_snapshot ? original_storage_snapshot->storage.canMoveConditionsToPrewhere() : false;
|
|
|
|
}
|
2023-02-24 12:46:09 +00:00
|
|
|
|
2023-06-02 21:41:25 +00:00
|
|
|
StorageSnapshotPtr getStorageSnapshot(const StorageMetadataPtr & metadata_snapshot, ContextPtr /*query_context*/) const override
|
|
|
|
{
|
|
|
|
return std::make_shared<StorageSnapshot>(*this, metadata_snapshot, object_columns);
|
|
|
|
}
|
|
|
|
|
2023-02-24 12:46:09 +00:00
|
|
|
QueryProcessingStage::Enum getQueryProcessingStage(
|
|
|
|
ContextPtr local_context,
|
|
|
|
QueryProcessingStage::Enum to_stage,
|
|
|
|
const StorageSnapshotPtr & storage_snapshot,
|
|
|
|
SelectQueryInfo & query_info) const override;
|
|
|
|
|
|
|
|
void read(
|
|
|
|
QueryPlan & query_plan,
|
|
|
|
const Names & column_names,
|
|
|
|
const StorageSnapshotPtr & storage_snapshot,
|
|
|
|
SelectQueryInfo & query_info,
|
|
|
|
ContextPtr local_context,
|
|
|
|
QueryProcessingStage::Enum processed_stage,
|
|
|
|
size_t max_block_size,
|
|
|
|
size_t num_streams) override;
|
2024-02-20 09:34:10 +00:00
|
|
|
|
2023-06-02 21:41:25 +00:00
|
|
|
private:
|
|
|
|
const ColumnsDescription object_columns;
|
2024-02-20 09:34:10 +00:00
|
|
|
|
2024-02-20 15:38:05 +00:00
|
|
|
/// The original storage snapshot which is replaced during planning. See collectFiltersForAnalysis for example.
|
|
|
|
StorageSnapshotPtr original_storage_snapshot;
|
2023-02-24 12:46:09 +00:00
|
|
|
};
|
|
|
|
|
2023-08-24 10:32:56 +00:00
|
|
|
class ReadFromDummy final : public SourceStepWithFilter
|
2023-02-24 12:46:09 +00:00
|
|
|
{
|
|
|
|
public:
|
2024-02-20 09:34:10 +00:00
|
|
|
explicit ReadFromDummy(
|
|
|
|
const Names & column_names_,
|
|
|
|
const SelectQueryInfo & query_info_,
|
|
|
|
const StorageSnapshotPtr & storage_snapshot_,
|
|
|
|
const ContextPtr & context_,
|
|
|
|
const StorageDummy & storage_);
|
2023-02-24 12:46:09 +00:00
|
|
|
|
|
|
|
const StorageDummy & getStorage() const
|
|
|
|
{
|
|
|
|
return storage;
|
|
|
|
}
|
|
|
|
|
|
|
|
const StorageSnapshotPtr & getStorageSnapshot() const
|
|
|
|
{
|
|
|
|
return storage_snapshot;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Names & getColumnNames() const
|
|
|
|
{
|
|
|
|
return column_names;
|
|
|
|
}
|
|
|
|
|
|
|
|
String getName() const override { return "ReadFromDummy"; }
|
|
|
|
|
|
|
|
void initializePipeline(QueryPipelineBuilder & pipeline, const BuildQueryPipelineSettings & settings) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const StorageDummy & storage;
|
|
|
|
Names column_names;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|