2021-11-09 12:20:45 +00:00
|
|
|
#include <Storages/Hive/HiveSettings.h>
|
|
|
|
|
2021-11-22 02:52:10 +00:00
|
|
|
#if USE_HIVE
|
2021-11-06 02:31:15 +00:00
|
|
|
|
|
|
|
#include <Common/Exception.h>
|
|
|
|
#include <Parsers/ASTSetQuery.h>
|
|
|
|
#include <Parsers/ASTCreateQuery.h>
|
|
|
|
#include <Parsers/ASTFunction.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
|