2020-02-18 14:41:30 +00:00
|
|
|
#include "StorageLogSettings.h"
|
2023-02-04 14:28:31 +00:00
|
|
|
#include <Disks/StoragePolicy.h>
|
|
|
|
#include <Interpreters/Context.h>
|
2020-02-18 14:41:30 +00:00
|
|
|
#include <Parsers/ASTCreateQuery.h>
|
|
|
|
#include <Parsers/ASTSetQuery.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2023-02-04 14:28:31 +00:00
|
|
|
String getDiskName(ASTStorage & storage_def, ContextPtr context)
|
2020-02-18 14:41:30 +00:00
|
|
|
{
|
|
|
|
if (storage_def.settings)
|
|
|
|
{
|
|
|
|
SettingsChanges changes = storage_def.settings->changes;
|
2020-03-09 01:22:33 +00:00
|
|
|
for (const auto & change : changes)
|
2023-02-04 14:28:31 +00:00
|
|
|
{
|
|
|
|
/// How about both disk and storage_policy are specified?
|
2020-03-09 01:22:33 +00:00
|
|
|
if (change.name == "disk")
|
|
|
|
return change.value.safeGet<String>();
|
2023-02-04 14:28:31 +00:00
|
|
|
if (change.name == "storage_policy")
|
|
|
|
{
|
|
|
|
auto policy = context->getStoragePolicy(change.value.safeGet<String>());
|
|
|
|
return policy->getAnyDisk()->getName();
|
|
|
|
}
|
|
|
|
}
|
2020-02-18 14:41:30 +00:00
|
|
|
}
|
|
|
|
return "default";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|