#pragma once #include namespace DB { template class AggregateFunctionAvgWeighted final : public AggregateFunctionAvgBase> { public: using AggregateFunctionAvgBase>::AggregateFunctionAvgBase; using ColVecType = std::conditional_t, ColumnDecimal, ColumnVector>; void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override { const auto & values = static_cast(*columns[0]); const auto & weights = static_cast(*columns[1]); this->data(place).numerator += values.getData()[row_num] * weights.getData()[row_num]; this->data(place).denominator += weights.getData()[row_num]; } String getName() const override { return "avgWeighted"; } }; }