bkietz commented on code in PR #40223:
URL: https://github.com/apache/arrow/pull/40223#discussion_r1503066736
##########
cpp/src/arrow/compute/expression.cc:
##########
@@ -536,14 +566,21 @@ Result<Expression> BindNonRecursive(Expression::Call
call, bool insert_implicit_
std::vector<TypeHolder> types = GetTypes(call.arguments);
ARROW_ASSIGN_OR_RAISE(call.function, GetFunction(call, exec_context));
- // First try and bind exactly
- Result<const Kernel*> maybe_exact_match =
call.function->DispatchExact(types);
- if (maybe_exact_match.ok()) {
- call.kernel = *maybe_exact_match;
- } else {
- if (!insert_implicit_casts) {
- return maybe_exact_match.status();
+ bool maybe_need_dispatch_best = IsNeedDispatchBest(types,
call.function_name);
Review Comment:
Instead of putting a special case here, I'd prefer to see
ResolveDecimalAdditionOrSubtractionOutput amended. I think it would be
sufficient to make the change
```diff
diff --git a/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
b/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
index 44f5fea79..8aa14aa3f 100644
--- a/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
@@ -499,8 +499,9 @@ Result<TypeHolder> ResolveDecimalBinaryOperationOutput(
DCHECK_EQ(left_type.id(), right_type.id());
int32_t precision, scale;
- std::tie(precision, scale) = getter(left_type.precision(),
left_type.scale(),
- right_type.precision(),
right_type.scale());
+ ARROW_ASSIGN_OR_RAISE(std::tie(precision, scale),
+ ToResult(getter(left_type.precision(),
left_type.scale(),
+ right_type.precision(),
right_type.scale())));
ARROW_ASSIGN_OR_RAISE(auto type, DecimalType::Make(left_type.id(),
precision, scale));
return std::move(type);
}
@@ -508,7 +509,12 @@ Result<TypeHolder> ResolveDecimalBinaryOperationOutput(
Result<TypeHolder> ResolveDecimalAdditionOrSubtractionOutput(
KernelContext*, const std::vector<TypeHolder>& types) {
return ResolveDecimalBinaryOperationOutput(
- types, [](int32_t p1, int32_t s1, int32_t p2, int32_t s2) {
+ types,
+ [](int32_t p1, int32_t s1, int32_t p2,
+ int32_t s2) -> Result<std::pair<int32_t, int32_t>> {
+ if (s1 != s2) {
+ return Status::Invalid("");
+ }
DCHECK_EQ(s1, s2);
const int32_t scale = s1;
const int32_t precision = std::max(p1 - s1, p2 - s2) + scale + 1;
```
--
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]