From ad54825dfe1e442c6dd1fb044911e0f2d2c3d69b Mon Sep 17 00:00:00 2001 From: Andrey Mironov Date: Wed, 4 Feb 2015 16:06:56 +0300 Subject: [PATCH] dbms: uncomment clickhouse dictionary source creation [#METR-13298] --- .../DB/Dictionaries/DictionarySourceFactory.h | 4 +-- dbms/src/Interpreters/Dictionaries.cpp | 25 ++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/dbms/include/DB/Dictionaries/DictionarySourceFactory.h b/dbms/include/DB/Dictionaries/DictionarySourceFactory.h index b6678d11b57..e153e3bb21d 100644 --- a/dbms/include/DB/Dictionaries/DictionarySourceFactory.h +++ b/dbms/include/DB/Dictionaries/DictionarySourceFactory.h @@ -60,8 +60,8 @@ public: } else if (config.has(config_prefix + "clickhouse")) { - return nullptr;//ext::make_unique(config, config_prefix + "clickhouse.", - //sample_block, context); + ext::make_unique(config, config_prefix + "clickhouse.", + sample_block, context); } throw Exception{"unsupported source type"}; diff --git a/dbms/src/Interpreters/Dictionaries.cpp b/dbms/src/Interpreters/Dictionaries.cpp index d93d0bd49c4..2fb20c68019 100644 --- a/dbms/src/Interpreters/Dictionaries.cpp +++ b/dbms/src/Interpreters/Dictionaries.cpp @@ -7,11 +7,30 @@ namespace DB { +namespace +{ + std::string getDictionariesConfigPath(const Poco::Util::AbstractConfiguration & config) + { + const auto path = config.getString("dictionaries_config"); + if (path.empty()) + return path; + + if (path[0] != '/') + { + const auto app_config_path = config.getString("config-file", "config.xml"); + const auto config_dir = Poco::Path{app_config_path}.parent().toString(); + const auto absolute_path = config_dir + path; + if (Poco::File{absolute_path}.exists()) + return absolute_path; + } + + return path; + } +} + void Dictionaries::reloadExternals() { - const auto config_path = Poco::Util::Application::instance().config().getString("dictionaries_config"); - if (config_path.empty()) - return; + const auto config_path = getDictionariesConfigPath(Poco::Util::Application::instance().config()); const auto last_modified = Poco::File{config_path}.getLastModified(); if (last_modified > dictionaries_last_modified)