pitrou commented on code in PR #47479:
URL: https://github.com/apache/arrow/pull/47479#discussion_r2318058602
##########
cpp/src/arrow/compute/expression_test.cc:
##########
@@ -717,6 +717,51 @@ TEST(Expression, BindWithImplicitCasts) {
call("is_in", {cast(field_ref("dict_str"), utf8())}, in_a));
}
+TEST(Expression, BindWithImplicitCastsForCaseWhenOnDecimal) {
+ auto exciting_schema = schema(
Review Comment:
I'm excited 🤩
##########
cpp/src/arrow/compute/kernels/scalar_if_else.cc:
##########
@@ -1451,6 +1451,23 @@ struct CaseWhenFunction : ScalarFunction {
if (auto kernel = DispatchExactImpl(this, *types)) return kernel;
return arrow::compute::detail::NoMatchingKernel(this, *types);
}
+
+ static std::shared_ptr<MatchConstraint> DecimalMatchConstraint() {
+ static auto constraint =
+ MatchConstraint::Make([](const std::vector<TypeHolder>& types) -> bool
{
+ DCHECK_GE(types.size(), 2);
+ DCHECK(std::all_of(types.begin() + 1, types.end(), [](const
TypeHolder& type) {
+ return is_decimal(type.id());
+ }));
+ const auto& ty1 = checked_cast<const DecimalType&>(*types[1].type);
Review Comment:
Is the cast actually needed? The `Equals` method should work as well without
it.
--
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]