diff --git a/src/AggregateFunctions/AggregateFunctionGroupArray.h b/src/AggregateFunctions/AggregateFunctionGroupArray.h index e8c4d70ea26..27a8cf0b1ee 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupArray.h +++ b/src/AggregateFunctions/AggregateFunctionGroupArray.h @@ -112,7 +112,6 @@ class GroupArrayNumericImpl final { using Data = GroupArrayNumericData; static constexpr bool limit_num_elems = Trait::has_limit; - DataTypePtr & data_type; UInt64 max_elems; UInt64 seed; @@ -121,7 +120,6 @@ public: const DataTypePtr & data_type_, UInt64 max_elems_ = std::numeric_limits::max(), UInt64 seed_ = 123456) : IAggregateFunctionDataHelper, GroupArrayNumericImpl>( {data_type_}, {}) - , data_type(this->argument_types[0]) , max_elems(max_elems_) , seed(seed_) { @@ -129,7 +127,7 @@ public: String getName() const override { return getNameByTrait(); } - DataTypePtr getReturnType() const override { return std::make_shared(data_type); } + DataTypePtr getReturnType() const override { return std::make_shared(this->argument_types[0]); } void insert(Data & a, const T & v, Arena * arena) const { diff --git a/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h b/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h index 2ee9d0f6e1c..1dc7dcde9c3 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h +++ b/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h @@ -56,7 +56,7 @@ public: DataTypePtr getReturnType() const override { - return std::make_shared(std::make_shared>()); + return std::make_shared(this->argument_types[0]); } void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override diff --git a/tests/queries/0_stateless/01651_group_uniq_array_enum.reference b/tests/queries/0_stateless/01651_group_uniq_array_enum.reference index 2858c6f9a95..ba4401b6afd 100644 --- a/tests/queries/0_stateless/01651_group_uniq_array_enum.reference +++ b/tests/queries/0_stateless/01651_group_uniq_array_enum.reference @@ -1,2 +1,3 @@ ['Hello','World','Упячка'] ['Hello','World','World','Упячка','Упячка','Упячка'] +['world','hello'] Array(Enum8(\'world\' = 0, \'hello\' = 1)) ['world','hello'] Array(Enum8(\'world\' = 0, \'hello\' = 1)) diff --git a/tests/queries/0_stateless/01651_group_uniq_array_enum.sql b/tests/queries/0_stateless/01651_group_uniq_array_enum.sql index b20cb17dd21..19de51f9681 100644 --- a/tests/queries/0_stateless/01651_group_uniq_array_enum.sql +++ b/tests/queries/0_stateless/01651_group_uniq_array_enum.sql @@ -1,2 +1,13 @@ SELECT arraySort(groupUniqArray(x)) FROM (SELECT CAST(arrayJoin([1, 2, 3, 2, 3, 3]) AS Enum('Hello' = 1, 'World' = 2, 'Упячка' = 3)) AS x); SELECT arraySort(groupArray(x)) FROM (SELECT CAST(arrayJoin([1, 2, 3, 2, 3, 3]) AS Enum('Hello' = 1, 'World' = 2, 'Упячка' = 3)) AS x); + +SELECT + arraySort(groupUniqArray(val)) AS uniq, + toTypeName(uniq), + arraySort(groupArray(val)) AS arr, + toTypeName(arr) +FROM +( + SELECT CAST(number % 2, 'Enum(\'hello\' = 1, \'world\' = 0)') AS val + FROM numbers(2) +);