zanmato1984 commented on code in PR #50870:
URL: https://github.com/apache/arrow/pull/50870#discussion_r3910995882
##########
cpp/src/arrow/compute/kernels/scalar_if_else_test.cc:
##########
@@ -3693,8 +3693,22 @@ TEST(TestCoalesce, DispatchBest) {
CheckDispatchBest("coalesce", {int32(), decimal128(3, 2)},
{decimal128(12, 2), decimal128(12, 2)});
CheckDispatchBest("coalesce", {float32(), decimal128(3, 2)}, {float64(),
float64()});
+ CheckDispatchBest("coalesce", {decimal128(3, 2), decimal128(4, 2)},
+ {decimal128(4, 2), decimal128(4, 2)});
+ CheckDispatchBest("coalesce", {decimal128(4, 2), decimal128(3, 2)},
+ {decimal128(4, 2), decimal128(4, 2)});
+ CheckDispatchBest("coalesce", {decimal128(4, 1), decimal128(3, 2)},
+ {decimal128(5, 2), decimal128(5, 2)});
+ CheckDispatchBest("coalesce", {decimal128(3, 2), decimal128(4, 1)},
+ {decimal128(5, 2), decimal128(5, 2)});
+ CheckDispatchBest("coalesce", {decimal128(3, 2), decimal128(4, 3)},
+ {decimal128(4, 3), decimal128(4, 3)});
+ CheckDispatchBest("coalesce", {decimal128(4, 3), decimal128(3, 2)},
+ {decimal128(4, 3), decimal128(4, 3)});
CheckDispatchBest("coalesce", {decimal128(3, 2), decimal256(3, 2)},
{decimal256(3, 2), decimal256(3, 2)});
+ CheckDispatchBest("coalesce", {decimal256(3, 2), decimal128(3, 2)},
Review Comment:
Good catch. I added this case in both argument orders. The common type is
`decimal256(5, 2)`, and the binding tests verify that both inputs are cast to
it.
##########
cpp/src/arrow/compute/kernels/scalar_if_else.cc:
##########
@@ -2035,6 +2035,20 @@ struct CoalesceFunction : ScalarFunction {
if (auto kernel = DispatchExactImpl(this, *types)) return kernel;
return arrow::compute::detail::NoMatchingKernel(this, *types);
}
+
+ static std::shared_ptr<MatchConstraint> DecimalMatchConstraint() {
Review Comment:
Agreed. I moved the constraint to `kernel.h` / `kernel.cc` and generalized
it as `AllTypesAreIdentical()` and
`AllTypesAreIdenticalFrom(first_type_index)`. `coalesce` uses the former, while
`case_when` uses `AllTypesAreIdenticalFrom(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]