blob: 4e643db8470b9582c20552b160df540f12c6906f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include <Processors/Transforms/finalizeChunk.h>
#include <Columns/ColumnAggregateFunction.h>
namespace DB
{
ColumnsMask getAggregatesMask(const Block & header, const AggregateDescriptions & aggregates)
{
ColumnsMask mask(header.columns());
for (const auto & aggregate : aggregates)
mask[header.getPositionByName(aggregate.column_name)] = true;
return mask;
}
void finalizeChunk(Chunk & chunk, const ColumnsMask & aggregates_mask)
{
auto num_rows = chunk.getNumRows();
auto columns = chunk.detachColumns();
for (size_t i = 0; i < columns.size(); ++i)
{
if (!aggregates_mask[i])
continue;
auto & column = columns[i];
column = ColumnAggregateFunction::convertToValues(IColumn::mutate(std::move(column)));
}
chunk.setColumns(std::move(columns), num_rows);
}
}
|