From cb68180cdf39f8ba8c14d5e49e96c2d6e9f05e90 Mon Sep 17 00:00:00 2001 From: BiteTheDDDDt <952130278@qq.com> Date: Fri, 29 Jul 2022 15:22:03 +0800 Subject: [PATCH] fix align of AggregateFunctionDistinct --- src/AggregateFunctions/AggregateFunctionDistinct.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 {