MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / loadFromQuery

Method loadFromQuery

src/Databases/DatabaseMetadataDiskSettings.cpp:28–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26IMPLEMENT_SETTINGS_TRAITS_CUSTOM_IMPL(DatabaseMetadataDiskSettingsTraits, LIST_OF_DATABASE_METADATA_DISK_SETTINGS, DatabaseMetadataDiskSettings, DatabaseMetadataDiskSetting)
27
28void 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
62DatabaseMetadataDiskSettings::DatabaseMetadataDiskSettings() : impl(std::make_unique<DatabaseMetadataDiskSettingsImpl>())

Callers

nothing calls this directly

Calls 5

isDiskFunctionFunction · 0.85
tryGetMethod · 0.45
getTypeNameMethod · 0.45
getImplMethod · 0.45
getDiskMethod · 0.45

Tested by

no test coverage detected