diff --git a/src/AggregateFunctions/AggregateFunctionDistinct.h b/src/AggregateFunctions/AggregateFunctionDistinct.h index 91e25ddfdfd..5afe104bcc0 100644 --- a/src/AggregateFunctions/AggregateFunctionDistinct.h +++ b/src/AggregateFunctions/AggregateFunctionDistinct.h @@ -152,8 +152,8 @@ template class AggregateFunctionDistinct : public IAggregateFunctionDataHelper> { private: - static constexpr auto prefix_size = sizeof(Data); AggregateFunctionPtr nested_func; + size_t prefix_size; size_t arguments_num; AggregateDataPtr getNestedPlace(AggregateDataPtr __restrict place) const noexcept @@ -170,7 +170,11 @@ public: AggregateFunctionDistinct(AggregateFunctionPtr nested_func_, const DataTypes & arguments, const Array & params_) : IAggregateFunctionDataHelper(arguments, params_) , nested_func(nested_func_) - , arguments_num(arguments.size()) {} + , arguments_num(arguments.size()) + { + size_t nested_size = nested_func->alignOfData(); + prefix_size = (sizeof(Data) + nested_size - 1) / nested_size * nested_size; + } void add(AggregateDataPtr __restrict place, const IColumn ** columns, size_t row_num, Arena * arena) const override {