fix TTL with GROUP BY

This commit is contained in:
Anton Popov 2020-12-29 18:19:11 +03:00
parent b60c00ba74
commit a8f1786d95
2 changed files with 6 additions and 4 deletions

View File

@ -26,7 +26,6 @@ void TTLColumnAlgorithm::execute(Block & block)
if (!block)
return;
/// If we read not all table columns. E.g. while mutation.
if (!block.has(column_name))
return;

View File

@ -211,9 +211,12 @@ TTLDescription TTLDescription::getTTLFromAST(
const auto & primary_key_expressions = primary_key.expression_list_ast->children;
for (size_t i = ttl_element->group_by_key.size(); i < primary_key_expressions.size(); ++i)
{
ASTPtr expr = makeASTFunction("any", primary_key_expressions[i]->clone());
aggregations.emplace_back(pk_columns[i], std::move(expr));
aggregation_columns_set.insert(pk_columns[i]);
if (!aggregation_columns_set.count(pk_columns[i]))
{
ASTPtr expr = makeASTFunction("any", primary_key_expressions[i]->clone());
aggregations.emplace_back(pk_columns[i], std::move(expr));
aggregation_columns_set.insert(pk_columns[i]);
}
}
for (const auto & column : columns.getOrdinary())