2017-04-25 09:10:27 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Storages/IStorage.h>
|
2017-06-23 15:55:45 +00:00
|
|
|
#include <ext/shared_ptr_helper.h>
|
2017-04-25 09:10:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2017-06-26 08:54:58 +00:00
|
|
|
struct DictionaryStructure;
|
2017-04-25 09:10:27 +00:00
|
|
|
|
2020-03-19 23:48:53 +00:00
|
|
|
class StorageDictionary final : public ext::shared_ptr_helper<StorageDictionary>, public IStorage
|
2017-04-25 09:10:27 +00:00
|
|
|
{
|
2019-08-26 19:07:29 +00:00
|
|
|
friend struct ext::shared_ptr_helper<StorageDictionary>;
|
2017-04-25 09:10:27 +00:00
|
|
|
public:
|
|
|
|
std::string getName() const override { return "Dictionary"; }
|
2019-07-09 15:40:21 +00:00
|
|
|
|
2020-04-09 23:25:52 +00:00
|
|
|
void checkTableCanBeDropped() const override;
|
|
|
|
|
2020-08-03 13:54:14 +00:00
|
|
|
Pipe read(
|
2020-06-15 19:08:58 +00:00
|
|
|
const Names & column_names,
|
|
|
|
const StorageMetadataPtr & /*metadata_snapshot*/,
|
2017-07-15 03:48:36 +00:00
|
|
|
const SelectQueryInfo & query_info,
|
2017-04-25 09:10:27 +00:00
|
|
|
const Context & context,
|
2018-04-19 14:47:09 +00:00
|
|
|
QueryProcessingStage::Enum processed_stage,
|
2020-02-20 14:40:58 +00:00
|
|
|
size_t max_block_size,
|
|
|
|
unsigned threads) override;
|
2020-01-31 08:14:20 +00:00
|
|
|
|
2017-12-25 21:57:29 +00:00
|
|
|
static NamesAndTypesList getNamesAndTypes(const DictionaryStructure & dictionary_structure);
|
2020-04-12 20:50:32 +00:00
|
|
|
static String generateNamesAndTypesDescription(const NamesAndTypesList & list);
|
2018-03-13 13:28:32 +00:00
|
|
|
|
2020-09-22 11:56:40 +00:00
|
|
|
const String & dictionaryName() const { return dictionary_name; }
|
|
|
|
String resolvedDictionaryName() const;
|
2020-04-08 18:59:52 +00:00
|
|
|
|
2020-07-05 14:14:20 +00:00
|
|
|
/// Specifies where the table is located relative to the dictionary.
|
|
|
|
enum class Location
|
|
|
|
{
|
2020-07-05 15:44:28 +00:00
|
|
|
/// Table was created automatically as an element of a database with the Dictionary engine.
|
2020-07-05 14:14:20 +00:00
|
|
|
DictionaryDatabase,
|
|
|
|
|
|
|
|
/// Table was created automatically along with a dictionary
|
|
|
|
/// and has the same database and name as the dictionary.
|
|
|
|
/// It provides table-like access to the dictionary.
|
|
|
|
/// User cannot drop that table.
|
|
|
|
SameDatabaseAndNameAsDictionary,
|
|
|
|
|
|
|
|
/// Table was created explicitly by a statement like
|
|
|
|
/// CREATE TABLE ... ENGINE=Dictionary
|
2020-07-05 15:45:05 +00:00
|
|
|
/// User chose the table's database and name and can drop that table.
|
2020-07-05 14:14:20 +00:00
|
|
|
Custom,
|
|
|
|
};
|
|
|
|
|
2017-04-25 09:10:27 +00:00
|
|
|
private:
|
2020-07-03 13:36:08 +00:00
|
|
|
const String dictionary_name;
|
2020-07-05 14:14:20 +00:00
|
|
|
const Location location;
|
2017-04-28 18:33:31 +00:00
|
|
|
|
2017-11-03 21:50:22 +00:00
|
|
|
protected:
|
2019-07-09 15:40:21 +00:00
|
|
|
StorageDictionary(
|
2019-12-04 16:06:55 +00:00
|
|
|
const StorageID & table_id_,
|
2020-04-12 20:50:32 +00:00
|
|
|
const String & dictionary_name_,
|
2020-07-03 13:36:08 +00:00
|
|
|
const ColumnsDescription & columns_,
|
2020-07-05 14:14:20 +00:00
|
|
|
Location location_);
|
2020-07-03 13:36:08 +00:00
|
|
|
|
|
|
|
StorageDictionary(
|
|
|
|
const StorageID & table_id_,
|
|
|
|
const String & dictionary_name_,
|
|
|
|
const DictionaryStructure & dictionary_structure,
|
2020-07-05 14:14:20 +00:00
|
|
|
Location location_);
|
2017-04-25 09:10:27 +00:00
|
|
|
};
|
2017-11-03 21:50:22 +00:00
|
|
|
|
2017-05-15 13:58:40 +00:00
|
|
|
}
|