2020-06-12 04:21:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-08-07 16:14:10 +00:00
|
|
|
#include "config_core.h"
|
|
|
|
|
|
|
|
#if USE_MYSQL
|
|
|
|
|
2020-06-12 04:21:43 +00:00
|
|
|
#include <Storages/IStorage.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-09-14 19:25:02 +00:00
|
|
|
template<typename DatabaseT>
|
|
|
|
class StorageMaterializeMySQL final : public ext::shared_ptr_helper<StorageMaterializeMySQL<DatabaseT>>, public IStorage
|
2020-06-12 04:21:43 +00:00
|
|
|
{
|
2020-09-14 19:25:02 +00:00
|
|
|
//static_assert(std::is_same_v<DatabaseT, DatabaseMaterializeMySQL<DatabaseOrdinary>> ||
|
|
|
|
// std::is_same_v<DatabaseT, DatabaseMaterializeMySQL<DatabaseAtomic>>);
|
|
|
|
friend struct ext::shared_ptr_helper<StorageMaterializeMySQL<DatabaseT>>;
|
2020-06-12 04:21:43 +00:00
|
|
|
public:
|
2020-08-06 11:56:49 +00:00
|
|
|
String getName() const override { return "MaterializeMySQL"; }
|
2020-06-12 04:21:43 +00:00
|
|
|
|
|
|
|
bool supportsFinal() const override { return nested_storage->supportsFinal(); }
|
|
|
|
bool supportsSampling() const override { return nested_storage->supportsSampling(); }
|
|
|
|
|
2020-09-14 19:25:02 +00:00
|
|
|
StorageMaterializeMySQL(const StoragePtr & nested_storage_, const DatabaseT * database_);
|
2020-06-12 04:21:43 +00:00
|
|
|
|
2020-08-14 05:28:26 +00:00
|
|
|
Pipe read(
|
2020-07-01 05:00:50 +00:00
|
|
|
const Names & column_names, const StorageMetadataPtr & metadata_snapshot, const SelectQueryInfo & query_info,
|
2020-06-12 04:21:43 +00:00
|
|
|
const Context & context, QueryProcessingStage::Enum processed_stage, size_t max_block_size, unsigned num_streams) override;
|
|
|
|
|
2020-06-24 05:28:27 +00:00
|
|
|
NamesAndTypesList getVirtuals() const override;
|
|
|
|
|
2020-09-14 19:25:02 +00:00
|
|
|
StoragePtr getNested() const { return nested_storage; }
|
|
|
|
|
|
|
|
void drop() override { nested_storage->drop(); }
|
|
|
|
|
2020-06-12 04:21:43 +00:00
|
|
|
private:
|
|
|
|
StoragePtr nested_storage;
|
2020-09-14 19:25:02 +00:00
|
|
|
const DatabaseT * database;
|
2020-06-12 04:21:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2020-08-07 16:14:10 +00:00
|
|
|
|
|
|
|
#endif
|