taiyang-li commented on code in PR #8351:
URL: https://github.com/apache/incubator-gluten/pull/8351#discussion_r1903807650
##########
cpp-ch/local-engine/Functions/SparkFunctionCheckDecimalOverflow.cpp:
##########
@@ -192,20 +203,61 @@ class FunctionCheckDecimalOverflow : public IFunction
result_column = std::move(col_to);
}
- template <is_decimal FromFieldType, typename ToDataType>
+ template <typename FromDataType, typename ToDataType, typename
FromFieldType = FromDataType::FieldType>
requires(IsDataTypeDecimal<ToDataType>)
static bool convertToDecimalImpl(
- const FromFieldType & decimal, UInt32 precision_to, UInt32 scale_from,
UInt32 scale_to, typename ToDataType::FieldType & result)
+ const FromFieldType & value, UInt32 precision_to, UInt32 scale_from,
UInt32 scale_to, typename ToDataType::FieldType & result)
{
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
- return convertDecimalsImpl<DataTypeDecimal<Decimal256>,
ToDataType>(decimal, precision_to, scale_from, scale_to, result);
+ throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Convert from {} type
to decimal type is not implemented.", typeid(value).name());
+ }
+
+ template <typename FromDataType, typename ToDataType>
Review Comment:
directly use FromFieldType and ToFieldType as template parameters. There are
no references of FromDataType and ToDataType
--
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]