mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 11:52:27 +00:00
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
#include <Common/config.h>
|
|
|
|
#if USE_HDFS
|
|
#include <Common/Exception.h>
|
|
#include <Parsers/ASTSetQuery.h>
|
|
#include <Parsers/ASTCreateQuery.h>
|
|
#include <Parsers/ASTFunction.h>
|
|
#include <Storages/Hive/HiveSettings.h>
|
|
|
|
namespace DB
|
|
{
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int UNKNOWN_SETTING;
|
|
}
|
|
|
|
IMPLEMENT_SETTINGS_TRAITS(HiveSettingsTraits, LIST_OF_HIVE_SETTINGS)
|
|
|
|
void HiveSettings::loadFromConfig(const String & config_elem, const Poco::Util::AbstractConfiguration & config)
|
|
{
|
|
if (!config.has(config_elem))
|
|
return;
|
|
|
|
Poco::Util::AbstractConfiguration::Keys config_keys;
|
|
config.keys(config_elem, config_keys);
|
|
|
|
try
|
|
{
|
|
for (const String & key : config_keys)
|
|
set(key, config.getString(config_elem + "." + key));
|
|
}
|
|
catch (Exception & e)
|
|
{
|
|
if (e.code() == ErrorCodes::UNKNOWN_SETTING)
|
|
e.addMessage("in MergeTree config");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
void HiveSettings::loadFromQuery(ASTStorage & storage_def)
|
|
{
|
|
if (storage_def.settings)
|
|
{
|
|
try
|
|
{
|
|
applyChanges(storage_def.settings->changes);
|
|
}
|
|
catch (Exception & e)
|
|
{
|
|
if (e.code() == ErrorCodes::UNKNOWN_SETTING)
|
|
e.addMessage("for storage " + storage_def.engine->name);
|
|
throw;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
auto settings_ast = std::make_shared<ASTSetQuery>();
|
|
settings_ast->is_standalone = false;
|
|
storage_def.set(storage_def.settings, settings_ast);
|
|
}
|
|
}
|
|
|
|
}
|
|
#endif
|