| 26 | IMPLEMENT_SETTINGS_TRAITS_CUSTOM_IMPL(DatabaseMetadataDiskSettingsTraits, LIST_OF_DATABASE_METADATA_DISK_SETTINGS, DatabaseMetadataDiskSettings, DatabaseMetadataDiskSetting) |
| 27 | |
| 28 | void DatabaseMetadataDiskSettingsImpl::loadFromQuery(ASTStorage & storage_def, ContextPtr context, bool is_loading_from_existing_metadata) |
| 29 | { |
| 30 | if (!storage_def.settings) |
| 31 | return; |
| 32 | |
| 33 | auto changes = storage_def.settings->changes; |
| 34 | auto * value = changes.tryGet("disk"); |
| 35 | if (!value) |
| 36 | { |
| 37 | applyChanges(changes); |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | ASTPtr value_as_custom_ast = nullptr; |
| 42 | CustomType custom; |
| 43 | if (value->tryGet<CustomType>(custom) && 0 == strcmp(custom.getTypeName(), "AST")) |
| 44 | value_as_custom_ast = dynamic_cast<const FieldFromASTImpl &>(custom.getImpl()).ast; |
| 45 | |
| 46 | if (value_as_custom_ast && isDiskFunction(value_as_custom_ast)) |
| 47 | { |
| 48 | auto disk_name = DiskFromAST::createCustomDisk(value_as_custom_ast, context, is_loading_from_existing_metadata); |
| 49 | *value = disk_name; |
| 50 | } |
| 51 | else |
| 52 | { |
| 53 | DiskFromAST::ensureDiskIsNotCustom(value->safeGet<String>(), context); |
| 54 | } |
| 55 | [[maybe_unused]] auto disk = context->getDisk(value->safeGet<String>()); |
| 56 | chassert(disk); |
| 57 | |
| 58 | applyChanges(changes); |
| 59 | } |
| 60 | |
| 61 | |
| 62 | DatabaseMetadataDiskSettings::DatabaseMetadataDiskSettings() : impl(std::make_unique<DatabaseMetadataDiskSettingsImpl>()) |
nothing calls this directly
no test coverage detected