diff --git a/src/AggregateFunctions/AggregateFunctionAvg.h b/src/AggregateFunctions/AggregateFunctionAvg.h index 79f46e79992..d16824b71dc 100644 --- a/src/AggregateFunctions/AggregateFunctionAvg.h +++ b/src/AggregateFunctions/AggregateFunctionAvg.h @@ -326,7 +326,8 @@ public: #if USE_EMBEDDED_COMPILER - void compileAdd(llvm::IRBuilderBase & builder, llvm::Value * aggregate_data_ptr, const ValuesWithType & arguments) const override + void compileAddImpl(llvm::IRBuilderBase & builder, llvm::Value * aggregate_data_ptr, const ValuesWithType & arguments) const + requires(canBeNativeType() && canBeNativeType()) { llvm::IRBuilder<> & b = static_cast &>(builder); @@ -345,6 +346,12 @@ public: b.CreateStore(denominator_value_updated, denominator_ptr); } + void compileAdd(llvm::IRBuilderBase & builder, llvm::Value * aggregate_data_ptr, const ValuesWithType & arguments) const override + { + if constexpr(canBeNativeType() && canBeNativeType()) + compileAddImpl(builder, aggregate_data_ptr, arguments); + } + #endif private: diff --git a/src/AggregateFunctions/AggregateFunctionAvgWeighted.cpp b/src/AggregateFunctions/AggregateFunctionAvgWeighted.cpp index bcd295d72d8..7a01e34c919 100644 --- a/src/AggregateFunctions/AggregateFunctionAvgWeighted.cpp +++ b/src/AggregateFunctions/AggregateFunctionAvgWeighted.cpp @@ -94,6 +94,20 @@ public: b.CreateStore(denominator_value_updated, denominator_ptr); } + void + compileMerge(llvm::IRBuilderBase & builder, llvm::Value * aggregate_data_dst_ptr, llvm::Value * aggregate_data_src_ptr) const override + { + if constexpr (canBeNativeType() && canBeNativeType() && canBeNativeType()) + Base::compileMergeImpl(builder, aggregate_data_dst_ptr, aggregate_data_src_ptr); + } + + llvm::Value * compileGetResult(llvm::IRBuilderBase & builder, llvm::Value * aggregate_data_ptr) const override + { + if constexpr (canBeNativeType() && canBeNativeType() && canBeNativeType()) + return Base::compileGetResultImpl(builder, aggregate_data_ptr); + return nullptr; + } + void compileAdd(llvm::IRBuilderBase & builder, llvm::Value * aggregate_data_ptr, const ValuesWithType & arguments) const override { if constexpr (canBeNativeType() && canBeNativeType() && canBeNativeType()) @@ -110,7 +124,7 @@ bool allowTypes(const DataTypePtr& left, const DataTypePtr& right) noexcept constexpr auto allow = [](WhichDataType t) { - return t.isInt() || t.isUInt() || t.isFloat(); + return t.isInt() || t.isUInt() || t.isNativeFloat(); }; return allow(l_dt) && allow(r_dt); diff --git a/src/DataTypes/Native.h b/src/DataTypes/Native.h index 3edce1bb9cf..1900906204f 100644 --- a/src/DataTypes/Native.h +++ b/src/DataTypes/Native.h @@ -74,14 +74,12 @@ static inline llvm::Type * toNativeType(llvm::IRBuilderBase & builder) template static inline DataTypePtr toNativeDataType() { - if constexpr (std::is_same_v || std::is_same_v || + static_assert(std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v || std::is_same_v || - std::is_same_v || std::is_same_v) - return std::make_shared>(); - - throw Exception(ErrorCodes::LOGICAL_ERROR, "Invalid cast to native data type"); + std::is_same_v || std::is_same_v); + return std::make_shared>(); } /// Cast LLVM value with type to bool