validate direct dictionary lifetime is unset during creation

This commit is contained in:
Rory Crispin 2023-04-17 17:41:02 +02:00
parent 8bc0a3a899
commit 006af1dfa1
3 changed files with 15 additions and 0 deletions

View File

@ -571,11 +571,23 @@ void checkPrimaryKey(const AttributeNameToConfiguration & all_attrs, const Names
}
void checkLifetime(const ASTCreateQuery & query)
{
if (query.dictionary -> layout && query.dictionary->layout->layout_type == "direct") {
if (query.dictionary -> lifetime)
throw Exception(
ErrorCodes::BAD_ARGUMENTS,
"'lifetime' parameter is redundant for the dictionary' of layout '{}'",
query.dictionary->layout->layout_type);
}
}
DictionaryConfigurationPtr
getDictionaryConfigurationFromAST(const ASTCreateQuery & query, ContextPtr context, const std::string & database_)
{
checkAST(query);
checkLifetime(query);
AutoPtr<Poco::XML::Document> xml_document(new Poco::XML::Document());
AutoPtr<Poco::XML::Element> document_root(xml_document->createElement("dictionaries"));

View File

@ -0,0 +1,3 @@
CREATE TABLE IF NOT EXISTS dict_source (key UInt64, value String) ENGINE=MergeTree ORDER BY key;
CREATE DICTIONARY dict(`key` UInt64,`value` String) PRIMARY KEY key SOURCE(CLICKHOUSE(table 'dict_source')) LAYOUT(DIRECT()) LIFETIME(0); -- { serverError 36 }