EpsilonPrime commented on code in PR #33775:
URL: https://github.com/apache/arrow/pull/33775#discussion_r1083732426
##########
cpp/src/arrow/compute/kernels/scalar_round.cc:
##########
@@ -751,60 +877,25 @@ ArrayKernelExec
GenerateArithmeticWithFixedIntOutType(detail::GetTypeId get_id)
}
}
-struct ArithmeticFunction : ScalarFunction {
+struct RoundFunction : ScalarFunction {
using ScalarFunction::ScalarFunction;
Result<const Kernel*> DispatchBest(std::vector<TypeHolder>* types) const
override {
RETURN_NOT_OK(CheckArity(types->size()));
- RETURN_NOT_OK(CheckDecimals(types));
-
using arrow::compute::detail::DispatchExactImpl;
if (auto kernel = DispatchExactImpl(this, *types)) return kernel;
EnsureDictionaryDecoded(types);
- // Only promote types for binary functions
- if (types->size() == 2) {
- ReplaceNullWithOtherType(types);
- TimeUnit::type finest_unit;
- if (CommonTemporalResolution(types->data(), types->size(),
&finest_unit)) {
- ReplaceTemporalTypes(finest_unit, types);
- } else {
- if (TypeHolder type = CommonNumeric(*types)) {
- ReplaceTypes(type, types);
- }
- }
- }
-
if (auto kernel = DispatchExactImpl(this, *types)) return kernel;
return arrow::compute::detail::NoMatchingKernel(this, *types);
}
-
- Status CheckDecimals(std::vector<TypeHolder>* types) const {
- if (!HasDecimal(*types)) return Status::OK();
-
- if (types->size() == 2) {
- // "add_checked" -> "add"
- const auto func_name = name();
- const std::string op = func_name.substr(0, func_name.find("_"));
- if (op == "add" || op == "subtract") {
- return CastBinaryDecimalArgs(DecimalPromotion::kAdd, types);
- } else if (op == "multiply") {
- return CastBinaryDecimalArgs(DecimalPromotion::kMultiply, types);
- } else if (op == "divide") {
- return CastBinaryDecimalArgs(DecimalPromotion::kDivide, types);
- } else {
- return Status::Invalid("Invalid decimal function: ", func_name);
- }
- }
- return Status::OK();
- }
};
-/// An ArithmeticFunction that promotes only decimal arguments to double.
-struct ArithmeticDecimalToFloatingPointFunction : public ArithmeticFunction {
- using ArithmeticFunction::ArithmeticFunction;
+/// An RoundFunction that promotes only decimal arguments to double.
Review Comment:
updated.
--
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]