Merge pull request #23948 from azat/dict-range-min-max-check

Check MIN/MAX attributes in the list of dictionary attributes
This commit is contained in:
Maksim Kita 2021-05-08 16:07:26 +03:00 committed by GitHub
commit 80dbb7ca4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -161,6 +161,13 @@ void buildRangeConfiguration(AutoPtr<Document> doc, AutoPtr<Element> root, const
root->appendChild(element);
};
if (!all_attrs.count(range->min_attr_name))
throw Exception(ErrorCodes::INCORRECT_DICTIONARY_DEFINITION,
"MIN ({}) attribute is not defined in the dictionary attributes", range->min_attr_name);
if (!all_attrs.count(range->max_attr_name))
throw Exception(ErrorCodes::INCORRECT_DICTIONARY_DEFINITION,
"MAX ({}) attribute is not defined in the dictionary attributes", range->max_attr_name);
append_element("range_min", range->min_attr_name, all_attrs.at(range->min_attr_name));
append_element("range_max", range->max_attr_name, all_attrs.at(range->max_attr_name));
}

View File

@ -0,0 +1,11 @@
DROP DICTIONARY IF EXISTS dict_01864;
CREATE DICTIONARY dict_01864
(
`id` UInt64,
`value` String
)
PRIMARY KEY id
SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() TABLE 'does_not_exists'))
LIFETIME(MIN 0 MAX 1000)
LAYOUT(RANGE_HASHED())
RANGE(MIN first MAX last) -- { serverError 489 }