taiyang-li commented on code in PR #8351:
URL: https://github.com/apache/incubator-gluten/pull/8351#discussion_r1905071427
##########
cpp-ch/local-engine/Functions/SparkFunctionCheckDecimalOverflow.cpp:
##########
@@ -192,20 +190,62 @@ class FunctionCheckDecimalOverflow : public IFunction
result_column = std::move(col_to);
}
- template <is_decimal FromFieldType, typename ToDataType>
+ template <typename FromDataType, typename ToDataType>
requires(IsDataTypeDecimal<ToDataType>)
static bool convertToDecimalImpl(
- const FromFieldType & decimal, UInt32 precision_to, UInt32 scale_from,
UInt32 scale_to, typename ToDataType::FieldType & result)
+ const FromDataType::FieldType & value, UInt32 precision_to, UInt32
scale_from, UInt32 scale_to, typename ToDataType::FieldType & result)
{
+ using FromFieldType = typename FromDataType::FieldType;
if constexpr (std::is_same_v<FromFieldType, Decimal32>)
- return convertDecimalsImpl<DataTypeDecimal<Decimal32>,
ToDataType>(decimal, precision_to, scale_from, scale_to, result);
-
+ return convertDecimalsImpl<DataTypeDecimal<Decimal32>,
ToDataType>(value, precision_to, scale_from, scale_to, result);
else if constexpr (std::is_same_v<FromFieldType, Decimal64>)
- return convertDecimalsImpl<DataTypeDecimal<Decimal64>,
ToDataType>(decimal, precision_to, scale_from, scale_to, result);
+ return convertDecimalsImpl<DataTypeDecimal<Decimal64>,
ToDataType>(value, precision_to, scale_from, scale_to, result);
else if constexpr (std::is_same_v<FromFieldType, Decimal128>)
- return convertDecimalsImpl<DataTypeDecimal<Decimal128>,
ToDataType>(decimal, precision_to, scale_from, scale_to, result);
+ return convertDecimalsImpl<DataTypeDecimal<Decimal128>,
ToDataType>(value, precision_to, scale_from, scale_to, result);
+ else if constexpr (std::is_same_v<FromFieldType, Decimal256>)
+ return convertDecimalsImpl<DataTypeDecimal<Decimal256>,
ToDataType>(value, precision_to, scale_from, scale_to, result);
+ else if constexpr (IsDataTypeNumber<FromDataType>)
+ return convertNumberToDecimalImpl<DataTypeNumber<FromFieldType>,
ToDataType>(value, precision_to, scale_to, result);
+ else
+ throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Convert from {} type
to decimal type is not implemented.", typeid(value).name());
+ }
+
+ template <typename FromDataType, typename ToDataType>
+ requires(IsDataTypeNumber<FromDataType> && IsDataTypeDecimal<ToDataType>)
+ static bool convertNumberToDecimalImpl(
Review Comment:
ALWAYS_INLINE
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]