Skip to content

Commit

Permalink
Apply the same to arrayReduce
Browse files Browse the repository at this point in the history
  • Loading branch information
Algunenano committed Nov 16, 2023
1 parent e53e723 commit a0840d3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Functions/array/arrayReduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,19 @@ ColumnPtr FunctionArrayReduce::executeImpl(const ColumnsWithTypeAndName & argume
that->addBatchArray(0, input_rows_count, places.data(), 0, aggregate_arguments, offsets->data(), arena.get());
}

for (size_t i = 0; i < input_rows_count; ++i)
/// We should use insertMergeResultInto to insert result into ColumnAggregateFunction
/// correctly if result contains AggregateFunction's states
agg_func.insertMergeResultInto(places[i], res_col, arena.get());
if (agg_func.isState())
{
for (size_t i = 0; i < input_rows_count; ++i)
/// We should use insertMergeResultInto to insert result into ColumnAggregateFunction
/// correctly if result contains AggregateFunction's states
agg_func.insertMergeResultInto(places[i], res_col, arena.get());
}
else
{
for (size_t i = 0; i < input_rows_count; ++i)
agg_func.insertResultInto(places[i], res_col, arena.get());
}

return result_holder;
}

Expand Down

0 comments on commit a0840d3

Please sign in to comment.