mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-05 05:52:05 +00:00
45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
#include <Storages/Kafka/KafkaSettings.h>
|
|
#include <Parsers/ASTCreateQuery.h>
|
|
#include <Parsers/ASTSetQuery.h>
|
|
#include <Parsers/ASTFunction.h>
|
|
#include <Common/Exception.h>
|
|
#include <Core/SettingsCollectionImpl.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int BAD_ARGUMENTS;
|
|
extern const int UNKNOWN_SETTING;
|
|
}
|
|
|
|
IMPLEMENT_SETTINGS_COLLECTION(KafkaSettings, LIST_OF_KAFKA_SETTINGS)
|
|
|
|
void KafkaSettings::loadFromQuery(ASTStorage & storage_def)
|
|
{
|
|
if (storage_def.settings)
|
|
{
|
|
try
|
|
{
|
|
applyChanges(storage_def.settings->changes);
|
|
}
|
|
catch (Exception & e)
|
|
{
|
|
if (e.code() == ErrorCodes::UNKNOWN_SETTING)
|
|
throw Exception(e.message() + " for storage " + storage_def.engine->name, ErrorCodes::BAD_ARGUMENTS);
|
|
else
|
|
e.rethrow();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
auto settings_ast = std::make_shared<ASTSetQuery>();
|
|
settings_ast->is_standalone = false;
|
|
storage_def.set(storage_def.settings, settings_ast);
|
|
}
|
|
}
|
|
|
|
}
|