diff --git a/src/AggregateFunctions/AggregateFunctionGroupArray.h b/src/AggregateFunctions/AggregateFunctionGroupArray.h index 3255ea42edbe4f17ba154b56a57b0570b5065fcc..25f1a9b9ecfbae70992581d532ea16ab48a7e794 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 2ee9d0f6e1ca1e92845a0d5c69d37ca567b79585..1dc7dcde9c3ea90124b3b3d9039416e4338e1614 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 new file mode 100644 index 0000000000000000000000000000000000000000..ba4401b6afdfbfd18e8e60d7f57b8fc9223a84bd --- /dev/null +++ b/tests/queries/0_stateless/01651_group_uniq_array_enum.reference @@ -0,0 +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 new file mode 100644 index 0000000000000000000000000000000000000000..19de51f96816533e762ebdf0348eb11f8f16385f --- /dev/null +++ b/tests/queries/0_stateless/01651_group_uniq_array_enum.sql @@ -0,0 +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) +);