aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Backups/SettingsFieldOptionalString.cpp
blob: 573fd1e052c00e78ee006eb7d5b01725711bf41f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <Backups/SettingsFieldOptionalString.h>
#include <Common/ErrorCodes.h>

namespace DB
{

namespace ErrorCodes
{
    extern const int CANNOT_PARSE_BACKUP_SETTINGS;
}

SettingFieldOptionalString::SettingFieldOptionalString(const Field & field)
{
    if (field.getType() == Field::Types::Null)
    {
        value = std::nullopt;
        return;
    }

    if (field.getType() == Field::Types::String)
    {
        value = field.get<const String &>();
        return;
    }

    throw Exception(ErrorCodes::CANNOT_PARSE_BACKUP_SETTINGS, "Cannot get string from {}", field);
}

}