Check TTL in StorageFactory

This commit is contained in:
sundy-li 2019-10-14 17:03:39 +08:00
parent d1eb9b197b
commit b2109e4ece
2 changed files with 6 additions and 2 deletions

View File

@ -104,11 +104,12 @@ StoragePtr StorageFactory::get(
}
if ((storage_def->partition_by || storage_def->primary_key || storage_def->order_by || storage_def->sample_by ||
(query.columns_list && query.columns_list->indices && !query.columns_list->indices->children.empty()))
storage_def->ttl_table || !columns.getColumnTTLs().empty() ||
(query.columns_list && query.columns_list->indices && !query.columns_list->indices->children.empty()))
&& !endsWith(name, "MergeTree"))
{
throw Exception(
"Engine " + name + " doesn't support PARTITION BY, PRIMARY KEY, ORDER BY or SAMPLE BY clauses and skipping indices. "
"Engine " + name + " doesn't support PARTITION BY, PRIMARY KEY, ORDER BY, TTL or SAMPLE BY clauses and skipping indices. "
"Currently only the MergeTree family of engines supports them", ErrorCodes::BAD_ARGUMENTS);
}

View File

@ -57,4 +57,7 @@ create table ttl_00933_1 (d DateTime, a Int ttl 2 + 2) engine = MergeTree order
create table ttl_00933_1 (d DateTime, a Int ttl toDateTime(1)) engine = MergeTree order by tuple() partition by toSecond(d); -- { serverError 450 }
create table ttl_00933_1 (d DateTime, a Int ttl d - d) engine = MergeTree order by tuple() partition by toSecond(d); -- { serverError 450 }
create table ttl_00933_1 (d DateTime, a Int ttl d + interval 1 day) engine = Log; -- { serverError 36 }
create table ttl_00933_1 (d DateTime, a Int) engine = Log ttl d + interval 1 day; -- { serverError 36 }
drop table if exists ttl_00933_1;