fix segfault with -StateResample combinators

This commit is contained in:
Anton Popov 2020-07-06 02:17:46 +03:00
parent a5cbeda1e3
commit e2e92afd98

View File

@ -1181,15 +1181,17 @@ Block Aggregator::prepareBlockAndFill(
if (aggregate_functions[i]->isState())
{
/// The ColumnAggregateFunction column captures the shared ownership of the arena with aggregate function states.
ColumnAggregateFunction * column_aggregate_func = nullptr;
/// Aggregate state can be wrapped into array if aggregate function ends with -Resample combinator.
if (auto * column_array = typeid_cast<ColumnArray *>(final_aggregate_columns[i].get()))
column_aggregate_func = &assert_cast<ColumnAggregateFunction &>(column_array->getData());
else
column_aggregate_func = &assert_cast<ColumnAggregateFunction &>(*final_aggregate_columns[i]);
if (auto * column_aggregate_func = typeid_cast<ColumnAggregateFunction *>(final_aggregate_columns[i].get()))
for (auto & pool : data_variants.aggregates_pools)
column_aggregate_func->addArena(pool);
for (auto & pool : data_variants.aggregates_pools)
column_aggregate_func->addArena(pool);
/// Aggregate state can be wrapped into array if aggregate function ends with -Resample combinator.
final_aggregate_columns[i]->forEachSubcolumn([&data_variants](auto & subcolumn)
{
if (auto * column_aggregate_func = typeid_cast<ColumnAggregateFunction *>(subcolumn.get()))
for (auto & pool : data_variants.aggregates_pools)
column_aggregate_func->addArena(pool);
});
}
}
}