zhiqiang-hhhh commented on code in PR #32518: URL: https://github.com/apache/doris/pull/32518#discussion_r1540928087
########## be/src/vec/data_types/data_type_decimal.h: ########## @@ -411,39 +412,86 @@ constexpr bool IsDataTypeDecimalOrNumber = IsDataTypeDecimal<DataType> || IsDataTypeNumber<DataType>; // only for casting between other integral types and decimals +// in addition, this function also handles cast from data/datetime to decimals template <typename FromDataType, typename ToDataType, bool multiply_may_overflow, bool narrow_integral, typename RealFrom, typename RealTo> requires IsDataTypeDecimal<FromDataType> && IsDataTypeDecimal<ToDataType> void convert_to_decimals(RealTo* dst, const RealFrom* src, UInt32 scale_from, UInt32 scale_to, const typename ToDataType::FieldType& min_result, - const typename ToDataType::FieldType& max_result, size_t size) { + const typename ToDataType::FieldType& max_result, size_t size, + bool is_from_date, bool is_from_datetime) { Review Comment: we should check the source data type by deducting from template argument. ########## be/src/vec/data_types/data_type_decimal.h: ########## @@ -411,39 +412,86 @@ constexpr bool IsDataTypeDecimalOrNumber = IsDataTypeDecimal<DataType> || IsDataTypeNumber<DataType>; // only for casting between other integral types and decimals +// in addition, this function also handles cast from data/datetime to decimals template <typename FromDataType, typename ToDataType, bool multiply_may_overflow, bool narrow_integral, typename RealFrom, typename RealTo> requires IsDataTypeDecimal<FromDataType> && IsDataTypeDecimal<ToDataType> Review Comment: `requires (IsDataTypeDecimal || IsDateTimeV2Type || IsDateV2Type) && IsDataTypeDecimal<ToDataType>` ########## be/src/vec/data_types/data_type_decimal.h: ########## @@ -662,7 +710,8 @@ void convert_to_decimal(typename ToDataType::FieldType* dst, Decimal256, Decimal64>>; convert_to_decimals<DataTypeDecimal<DecimalFrom>, ToDataType, multiply_may_overflow, narrow_integral>(dst, src, from_scale, to_scale, min_result, max_result, - size); + size, IsDateV2Type<FromDataType>, + IsDateTimeV2Type<FromDataType>); Review Comment: IsDateTimeV2Type<FromDataType> should be move to function `convert_to_decimals`, and it will be something like `convert_to_decimals(...) { if constexpr (IsDateTimeV2Type<>) { } else if constexpr (IsDateV2Type) { } else { ... } } ` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org