| 1 | #include <Storages/Kafka/KafkaSettings.h> |
|---|---|
| 2 | #include <Parsers/ASTCreateQuery.h> |
| 3 | #include <Parsers/ASTSetQuery.h> |
| 4 | #include <Parsers/ASTFunction.h> |
| 5 | #include <Common/Exception.h> |
| 6 | #include <Core/SettingsCollectionImpl.h> |
| 7 | |
| 8 | |
| 9 | namespace DB |
| 10 | { |
| 11 | |
| 12 | namespace ErrorCodes |
| 13 | { |
| 14 | extern const int BAD_ARGUMENTS; |
| 15 | extern const int UNKNOWN_SETTING; |
| 16 | } |
| 17 | |
| 18 | IMPLEMENT_SETTINGS_COLLECTION(KafkaSettings, LIST_OF_KAFKA_SETTINGS) |
| 19 | |
| 20 | void KafkaSettings::loadFromQuery(ASTStorage & storage_def) |
| 21 | { |
| 22 | if (storage_def.settings) |
| 23 | { |
| 24 | try |
| 25 | { |
| 26 | applyChanges(storage_def.settings->changes); |
| 27 | } |
| 28 | catch (Exception & e) |
| 29 | { |
| 30 | if (e.code() == ErrorCodes::UNKNOWN_SETTING) |
| 31 | throw Exception(e.message() + " for storage "+ storage_def.engine->name, ErrorCodes::BAD_ARGUMENTS); |
| 32 | else |
| 33 | e.rethrow(); |
| 34 | } |
| 35 | } |
| 36 | else |
| 37 | { |
| 38 | auto settings_ast = std::make_shared<ASTSetQuery>(); |
| 39 | settings_ast->is_standalone = false; |
| 40 | storage_def.set(storage_def.settings, settings_ast); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | } |
| 45 |