diff --git a/dbms/include/DB/AggregateFunctions/AggregateFunctionGroupArray.h b/dbms/include/DB/AggregateFunctions/AggregateFunctionGroupArray.h index 987c20a4bef..5b9428af0b2 100644 --- a/dbms/include/DB/AggregateFunctions/AggregateFunctionGroupArray.h +++ b/dbms/include/DB/AggregateFunctions/AggregateFunctionGroupArray.h @@ -47,7 +47,7 @@ public: void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs) const { - data(place).value.insert(data(place).value.begin(), data(rhs).value.begin(), data(rhs).value.end()); + data(place).value.insert(data(place).value.end(), data(rhs).value.begin(), data(rhs).value.end()); } void serialize(ConstAggregateDataPtr place, WriteBuffer & buf) const diff --git a/dbms/tests/queries/0_stateless/00113_group_array.reference b/dbms/tests/queries/0_stateless/00113_group_array.reference new file mode 100644 index 00000000000..2b501e8d65a --- /dev/null +++ b/dbms/tests/queries/0_stateless/00113_group_array.reference @@ -0,0 +1,12 @@ +0 100 +1 100 +2 100 +3 100 +4 100 +5 100 +6 100 +7 100 +8 100 +9 100 + +0 1000000 diff --git a/dbms/tests/queries/0_stateless/00113_group_array.sql b/dbms/tests/queries/0_stateless/00113_group_array.sql new file mode 100644 index 00000000000..e9c2d0956ec --- /dev/null +++ b/dbms/tests/queries/0_stateless/00113_group_array.sql @@ -0,0 +1 @@ +SELECT intDiv(number, 100) AS k, length(groupArray(number)) FROM (SELECT * FROM system.numbers LIMIT 1000000) GROUP BY k WITH TOTALS ORDER BY k LIMIT 10;