2018-11-28 11:37:12 +00:00
|
|
|
#include "DictionaryStructure.h"
|
2018-12-10 15:25:45 +00:00
|
|
|
#include <Columns/IColumn.h>
|
2017-12-09 06:32:22 +00:00
|
|
|
#include <DataTypes/DataTypeFactory.h>
|
2018-09-13 13:33:44 +00:00
|
|
|
#include <DataTypes/DataTypeNullable.h>
|
2018-12-10 15:25:45 +00:00
|
|
|
#include <Formats/FormatSettings.h>
|
2017-12-09 06:32:22 +00:00
|
|
|
#include <IO/WriteHelpers.h>
|
2018-12-10 15:25:45 +00:00
|
|
|
#include <Common/StringUtils/StringUtils.h>
|
2016-06-07 21:07:44 +00:00
|
|
|
|
2017-12-09 06:32:22 +00:00
|
|
|
#include <numeric>
|
|
|
|
#include <unordered_map>
|
2018-12-10 15:25:45 +00:00
|
|
|
#include <unordered_set>
|
|
|
|
#include <ext/range.h>
|
2017-12-09 06:32:22 +00:00
|
|
|
|
2016-06-07 21:07:44 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
extern const int UNKNOWN_TYPE;
|
|
|
|
extern const int ARGUMENT_OUT_OF_BOUND;
|
|
|
|
extern const int TYPE_MISMATCH;
|
2017-04-08 01:32:05 +00:00
|
|
|
extern const int BAD_ARGUMENTS;
|
2016-06-07 21:07:44 +00:00
|
|
|
}
|
|
|
|
|
2018-09-13 13:33:44 +00:00
|
|
|
namespace
|
|
|
|
{
|
2018-12-10 15:25:45 +00:00
|
|
|
DictionaryTypedSpecialAttribute makeDictionaryTypedSpecialAttribute(
|
|
|
|
const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix, const std::string & default_type)
|
|
|
|
{
|
|
|
|
const auto name = config.getString(config_prefix + ".name", "");
|
|
|
|
const auto expression = config.getString(config_prefix + ".expression", "");
|
2018-09-13 13:33:44 +00:00
|
|
|
|
2018-12-10 15:25:45 +00:00
|
|
|
if (name.empty() && !expression.empty())
|
|
|
|
throw Exception{"Element " + config_prefix + ".name is empty", ErrorCodes::BAD_ARGUMENTS};
|
2018-09-13 13:33:44 +00:00
|
|
|
|
2018-12-10 15:25:45 +00:00
|
|
|
const auto type_name = config.getString(config_prefix + ".type", default_type);
|
|
|
|
return DictionaryTypedSpecialAttribute{std::move(name), std::move(expression), DataTypeFactory::instance().get(type_name)};
|
|
|
|
}
|
2018-09-13 13:33:44 +00:00
|
|
|
|
2019-06-13 10:43:37 +00:00
|
|
|
}
|
2018-09-13 13:33:44 +00:00
|
|
|
|
2016-06-07 21:07:44 +00:00
|
|
|
|
|
|
|
AttributeUnderlyingType getAttributeUnderlyingType(const std::string & type)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
static const std::unordered_map<std::string, AttributeUnderlyingType> dictionary{
|
2019-08-03 11:02:40 +00:00
|
|
|
{"UInt8", AttributeUnderlyingType::utUInt8},
|
|
|
|
{"UInt16", AttributeUnderlyingType::utUInt16},
|
|
|
|
{"UInt32", AttributeUnderlyingType::utUInt32},
|
|
|
|
{"UInt64", AttributeUnderlyingType::utUInt64},
|
|
|
|
{"UUID", AttributeUnderlyingType::utUInt128},
|
|
|
|
{"Int8", AttributeUnderlyingType::utInt8},
|
|
|
|
{"Int16", AttributeUnderlyingType::utInt16},
|
|
|
|
{"Int32", AttributeUnderlyingType::utInt32},
|
|
|
|
{"Int64", AttributeUnderlyingType::utInt64},
|
|
|
|
{"Float32", AttributeUnderlyingType::utFloat32},
|
|
|
|
{"Float64", AttributeUnderlyingType::utFloat64},
|
|
|
|
{"String", AttributeUnderlyingType::utString},
|
|
|
|
{"Date", AttributeUnderlyingType::utUInt16},
|
|
|
|
{"DateTime", AttributeUnderlyingType::utUInt32},
|
2017-04-01 07:20:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const auto it = dictionary.find(type);
|
|
|
|
if (it != std::end(dictionary))
|
|
|
|
return it->second;
|
|
|
|
|
2018-10-08 19:45:17 +00:00
|
|
|
if (type.find("Decimal") == 0)
|
|
|
|
{
|
|
|
|
size_t start = strlen("Decimal");
|
|
|
|
if (type.find("32", start) == start)
|
2019-08-03 11:02:40 +00:00
|
|
|
return AttributeUnderlyingType::utDecimal32;
|
2018-10-08 19:45:17 +00:00
|
|
|
if (type.find("64", start) == start)
|
2019-08-03 11:02:40 +00:00
|
|
|
return AttributeUnderlyingType::utDecimal64;
|
2018-10-08 19:45:17 +00:00
|
|
|
if (type.find("128", start) == start)
|
2019-08-03 11:02:40 +00:00
|
|
|
return AttributeUnderlyingType::utDecimal128;
|
2018-10-08 19:45:17 +00:00
|
|
|
}
|
|
|
|
|
2019-12-25 17:03:24 +00:00
|
|
|
// Temporary hack to allow arrays in keys, since they are never retrieved for polygon dictionaries.
|
|
|
|
// TODO: This should be fixed by fully supporting arrays in dictionaries.
|
2019-12-02 15:26:59 +00:00
|
|
|
if (type.find("Array") == 0)
|
|
|
|
return AttributeUnderlyingType::utString;
|
|
|
|
|
2018-05-07 02:01:11 +00:00
|
|
|
throw Exception{"Unknown type " + type, ErrorCodes::UNKNOWN_TYPE};
|
2016-06-07 21:07:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string toString(const AttributeUnderlyingType type)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utUInt8:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "UInt8";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utUInt16:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "UInt16";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utUInt32:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "UInt32";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utUInt64:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "UInt64";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utUInt128:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "UUID";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utInt8:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "Int8";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utInt16:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "Int16";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utInt32:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "Int32";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utInt64:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "Int64";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utFloat32:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "Float32";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utFloat64:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "Float64";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utDecimal32:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "Decimal32";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utDecimal64:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "Decimal64";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utDecimal128:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "Decimal128";
|
2019-08-03 11:02:40 +00:00
|
|
|
case AttributeUnderlyingType::utString:
|
2018-12-10 15:25:45 +00:00
|
|
|
return "String";
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
|
|
|
|
2018-05-07 02:01:11 +00:00
|
|
|
throw Exception{"Unknown attribute_type " + toString(static_cast<int>(type)), ErrorCodes::ARGUMENT_OUT_OF_BOUND};
|
2016-06-07 21:07:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DictionarySpecialAttribute::DictionarySpecialAttribute(const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix)
|
2018-12-10 15:25:45 +00:00
|
|
|
: name{config.getString(config_prefix + ".name", "")}, expression{config.getString(config_prefix + ".expression", "")}
|
2016-06-07 21:07:44 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
if (name.empty() && !expression.empty())
|
2018-05-07 02:01:11 +00:00
|
|
|
throw Exception{"Element " + config_prefix + ".name is empty", ErrorCodes::BAD_ARGUMENTS};
|
2016-06-07 21:07:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DictionaryStructure::DictionaryStructure(const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
const auto has_id = config.has(config_prefix + ".id");
|
|
|
|
const auto has_key = config.has(config_prefix + ".key");
|
|
|
|
|
|
|
|
if (has_key && has_id)
|
|
|
|
throw Exception{"Only one of 'id' and 'key' should be specified", ErrorCodes::BAD_ARGUMENTS};
|
|
|
|
|
|
|
|
if (has_id)
|
|
|
|
id.emplace(config, config_prefix + ".id");
|
|
|
|
else if (has_key)
|
|
|
|
{
|
|
|
|
key.emplace(getAttributes(config, config_prefix + ".key", false, false));
|
|
|
|
if (key->empty())
|
|
|
|
throw Exception{"Empty 'key' supplied", ErrorCodes::BAD_ARGUMENTS};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw Exception{"Dictionary structure should specify either 'id' or 'key'", ErrorCodes::BAD_ARGUMENTS};
|
|
|
|
|
|
|
|
if (id)
|
|
|
|
{
|
|
|
|
if (id->name.empty())
|
|
|
|
throw Exception{"'id' cannot be empty", ErrorCodes::BAD_ARGUMENTS};
|
|
|
|
|
2020-04-22 05:39:31 +00:00
|
|
|
const char * range_default_type = "Date";
|
2017-04-01 07:20:54 +00:00
|
|
|
if (config.has(config_prefix + ".range_min"))
|
2018-09-14 19:15:11 +00:00
|
|
|
range_min.emplace(makeDictionaryTypedSpecialAttribute(config, config_prefix + ".range_min", range_default_type));
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
if (config.has(config_prefix + ".range_max"))
|
2018-09-14 19:15:11 +00:00
|
|
|
range_max.emplace(makeDictionaryTypedSpecialAttribute(config, config_prefix + ".range_max", range_default_type));
|
2018-09-13 13:33:44 +00:00
|
|
|
|
|
|
|
if (range_min.has_value() != range_max.has_value())
|
|
|
|
{
|
2018-12-10 15:25:45 +00:00
|
|
|
throw Exception{"Dictionary structure should have both 'range_min' and 'range_max' either specified or not.",
|
|
|
|
ErrorCodes::BAD_ARGUMENTS};
|
2018-09-13 13:33:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (range_min && range_max && !range_min->type->equals(*range_max->type))
|
|
|
|
{
|
|
|
|
throw Exception{"Dictionary structure 'range_min' and 'range_max' should have same type, "
|
2018-12-10 15:25:45 +00:00
|
|
|
"'range_min' type: "
|
|
|
|
+ range_min->type->getName()
|
|
|
|
+ ", "
|
|
|
|
"'range_max' type: "
|
|
|
|
+ range_max->type->getName(),
|
|
|
|
ErrorCodes::BAD_ARGUMENTS};
|
2018-09-13 13:33:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (range_min)
|
|
|
|
{
|
|
|
|
if (!range_min->type->isValueRepresentedByInteger())
|
|
|
|
throw Exception{"Dictionary structure type of 'range_min' and 'range_max' should be an integer, Date, DateTime, or Enum."
|
2018-12-10 15:25:45 +00:00
|
|
|
" Actual 'range_min' and 'range_max' type is "
|
|
|
|
+ range_min->type->getName(),
|
|
|
|
ErrorCodes::BAD_ARGUMENTS};
|
2018-09-13 13:33:44 +00:00
|
|
|
}
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2018-12-10 15:25:45 +00:00
|
|
|
if (!id->expression.empty() || (range_min && !range_min->expression.empty()) || (range_max && !range_max->expression.empty()))
|
2017-04-01 07:20:54 +00:00
|
|
|
has_expressions = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes = getAttributes(config, config_prefix);
|
|
|
|
if (attributes.empty())
|
|
|
|
throw Exception{"Dictionary has no attributes defined", ErrorCodes::BAD_ARGUMENTS};
|
2016-06-07 21:07:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DictionaryStructure::validateKeyTypes(const DataTypes & key_types) const
|
|
|
|
{
|
2017-10-04 00:22:00 +00:00
|
|
|
if (key_types.size() != key->size())
|
2018-05-07 02:01:11 +00:00
|
|
|
throw Exception{"Key structure does not match, expected " + getKeyDescription(), ErrorCodes::TYPE_MISMATCH};
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
for (const auto i : ext::range(0, key_types.size()))
|
|
|
|
{
|
|
|
|
const auto & expected_type = (*key)[i].type->getName();
|
|
|
|
const auto & actual_type = key_types[i]->getName();
|
|
|
|
|
|
|
|
if (expected_type != actual_type)
|
2018-12-10 15:25:45 +00:00
|
|
|
throw Exception{"Key type at position " + std::to_string(i) + " does not match, expected " + expected_type + ", found "
|
|
|
|
+ actual_type,
|
|
|
|
ErrorCodes::TYPE_MISMATCH};
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2016-06-07 21:07:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string DictionaryStructure::getKeyDescription() const
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
if (id)
|
|
|
|
return "UInt64";
|
2016-06-07 21:07:44 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
std::ostringstream out;
|
2016-06-07 21:07:44 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
out << '(';
|
2016-06-07 21:07:44 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
auto first = true;
|
|
|
|
for (const auto & key_i : *key)
|
|
|
|
{
|
|
|
|
if (!first)
|
|
|
|
out << ", ";
|
2016-06-07 21:07:44 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
first = false;
|
2016-06-07 21:07:44 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
out << key_i.type->getName();
|
|
|
|
}
|
2016-06-07 21:07:44 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
out << ')';
|
2016-06-07 21:07:44 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
return out.str();
|
2016-06-07 21:07:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DictionaryStructure::isKeySizeFixed() const
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
if (!key)
|
|
|
|
return true;
|
2016-06-07 21:07:44 +00:00
|
|
|
|
2017-09-08 03:47:27 +00:00
|
|
|
for (const auto & key_i : *key)
|
2019-08-03 11:02:40 +00:00
|
|
|
if (key_i.underlying_type == AttributeUnderlyingType::utString)
|
2017-04-01 07:20:54 +00:00
|
|
|
return false;
|
2019-12-25 17:06:37 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
return true;
|
2016-06-07 21:07:44 +00:00
|
|
|
}
|
|
|
|
|
2017-07-21 06:35:58 +00:00
|
|
|
size_t DictionaryStructure::getKeySize() const
|
2016-06-07 21:07:44 +00:00
|
|
|
{
|
2018-12-10 15:25:45 +00:00
|
|
|
return std::accumulate(std::begin(*key), std::end(*key), size_t{}, [](const auto running_size, const auto & key_i)
|
|
|
|
{
|
|
|
|
return running_size + key_i.type->getSizeOfValueInMemory();
|
|
|
|
});
|
2016-06-07 21:07:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-08 01:51:55 +00:00
|
|
|
static void checkAttributeKeys(const Poco::Util::AbstractConfiguration::Keys & keys)
|
2017-01-31 13:27:02 +00:00
|
|
|
{
|
2018-12-10 15:25:45 +00:00
|
|
|
static const std::unordered_set<std::string> valid_keys
|
|
|
|
= {"name", "type", "expression", "null_value", "hierarchical", "injective", "is_object_id"};
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
for (const auto & key : keys)
|
|
|
|
{
|
|
|
|
if (valid_keys.find(key) == valid_keys.end())
|
2018-05-07 02:01:11 +00:00
|
|
|
throw Exception{"Unknown key '" + key + "' inside attribute section", ErrorCodes::BAD_ARGUMENTS};
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2017-01-31 13:27:02 +00:00
|
|
|
}
|
|
|
|
|
2018-06-08 01:51:55 +00:00
|
|
|
|
2016-06-07 21:07:44 +00:00
|
|
|
std::vector<DictionaryAttribute> DictionaryStructure::getAttributes(
|
2018-12-10 15:25:45 +00:00
|
|
|
const Poco::Util::AbstractConfiguration & config,
|
|
|
|
const std::string & config_prefix,
|
|
|
|
const bool hierarchy_allowed,
|
|
|
|
const bool allow_null_values)
|
2016-06-07 21:07:44 +00:00
|
|
|
{
|
2018-08-10 04:02:56 +00:00
|
|
|
Poco::Util::AbstractConfiguration::Keys config_elems;
|
|
|
|
config.keys(config_prefix, config_elems);
|
2017-04-01 07:20:54 +00:00
|
|
|
auto has_hierarchy = false;
|
|
|
|
|
2018-08-10 04:02:56 +00:00
|
|
|
std::vector<DictionaryAttribute> res_attributes;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2018-06-08 01:51:55 +00:00
|
|
|
const FormatSettings format_settings;
|
|
|
|
|
2018-08-10 04:02:56 +00:00
|
|
|
for (const auto & config_elem : config_elems)
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
2020-03-08 21:40:00 +00:00
|
|
|
if (!startsWith(config_elem, "attribute"))
|
2017-04-01 07:20:54 +00:00
|
|
|
continue;
|
|
|
|
|
2018-08-10 04:02:56 +00:00
|
|
|
const auto prefix = config_prefix + '.' + config_elem + '.';
|
2017-04-01 07:20:54 +00:00
|
|
|
Poco::Util::AbstractConfiguration::Keys attribute_keys;
|
2018-08-10 04:02:56 +00:00
|
|
|
config.keys(config_prefix + '.' + config_elem, attribute_keys);
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2018-06-08 01:51:55 +00:00
|
|
|
checkAttributeKeys(attribute_keys);
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
const auto name = config.getString(prefix + "name");
|
|
|
|
const auto type_string = config.getString(prefix + "type");
|
|
|
|
const auto type = DataTypeFactory::instance().get(type_string);
|
|
|
|
const auto underlying_type = getAttributeUnderlyingType(type_string);
|
|
|
|
|
|
|
|
const auto expression = config.getString(prefix + "expression", "");
|
|
|
|
if (!expression.empty())
|
|
|
|
has_expressions = true;
|
|
|
|
|
|
|
|
Field null_value;
|
|
|
|
if (allow_null_values)
|
|
|
|
{
|
|
|
|
const auto null_value_string = config.getString(prefix + "null_value");
|
|
|
|
try
|
|
|
|
{
|
2018-10-09 17:43:25 +00:00
|
|
|
if (null_value_string.empty())
|
|
|
|
null_value = type->getDefault();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ReadBufferFromString null_value_buffer{null_value_string};
|
|
|
|
auto column_with_null_value = type->createColumn();
|
2018-12-13 13:41:47 +00:00
|
|
|
type->deserializeAsTextEscaped(*column_with_null_value, null_value_buffer, format_settings);
|
2018-10-09 17:43:25 +00:00
|
|
|
null_value = (*column_with_null_value)[0];
|
|
|
|
}
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2017-12-15 03:04:33 +00:00
|
|
|
catch (Exception & e)
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
2017-12-15 03:04:33 +00:00
|
|
|
e.addMessage("error parsing null_value");
|
|
|
|
throw;
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto hierarchical = config.getBool(prefix + "hierarchical", false);
|
|
|
|
const auto injective = config.getBool(prefix + "injective", false);
|
2018-02-06 21:34:56 +00:00
|
|
|
const auto is_object_id = config.getBool(prefix + "is_object_id", false);
|
2017-04-01 07:20:54 +00:00
|
|
|
if (name.empty())
|
2018-05-07 02:01:11 +00:00
|
|
|
throw Exception{"Properties 'name' and 'type' of an attribute cannot be empty", ErrorCodes::BAD_ARGUMENTS};
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
if (has_hierarchy && !hierarchy_allowed)
|
2018-05-07 02:01:11 +00:00
|
|
|
throw Exception{"Hierarchy not allowed in '" + prefix, ErrorCodes::BAD_ARGUMENTS};
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
if (has_hierarchy && hierarchical)
|
2018-05-07 02:01:11 +00:00
|
|
|
throw Exception{"Only one hierarchical attribute supported", ErrorCodes::BAD_ARGUMENTS};
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
has_hierarchy = has_hierarchy || hierarchical;
|
|
|
|
|
2018-12-10 15:25:45 +00:00
|
|
|
res_attributes.emplace_back(
|
|
|
|
DictionaryAttribute{name, underlying_type, type, expression, null_value, hierarchical, injective, is_object_id});
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
|
|
|
|
2018-08-10 04:02:56 +00:00
|
|
|
return res_attributes;
|
2016-06-07 21:07:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|