ZhangHuiGui commented on code in PR #41363:
URL: https://github.com/apache/arrow/pull/41363#discussion_r1577578652


##########
cpp/src/arrow/compute/kernels/scalar_if_else.cc:
##########
@@ -1195,6 +1195,43 @@ struct ResolveIfElseExec<NullType, AllocateMem> {
   }
 };
 
+template <typename ResolverForOtherTypes>
+Result<TypeHolder> ResolveDecimalCaseType(KernelContext* ctx,
+                                          const std::vector<TypeHolder>& types,
+                                          ResolverForOtherTypes&& resolver) {
+  if (!HasDecimal(types)) {
+    return resolver(ctx, types);
+  }
+
+  int32_t max_precision = 0, max_scale = 0;
+  for (auto& type : types) {
+    if (is_floating(type.id()) || is_integer(type.id())) {
+      return Status::Invalid("Need to cast numeric types containing decimal 
types");
+    } else if (is_decimal(type.id())) {
+      const auto& decimal_type = checked_cast<const 
arrow::DecimalType&>(*type);
+      if (decimal_type.precision() < max_precision || decimal_type.scale() < 
max_scale) {

Review Comment:
   The returned invalid status used in the logic :
   
https://github.com/bkietz/arrow/blob/c25866bc59e30e43e8dc3b05f3973d48074c3594/cpp/src/arrow/compute/expression.cc#L551-L552
   
   Let the expression call go into `DispatchBest` so they can be cast correctly.



-- 
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]

Reply via email to