You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "kou (via GitHub)" <gi...@apache.org> on 2024/03/15 01:40:12 UTC

Re: [PR] GH-40308: [C++][Gandiva] Keep decimal divide rules same with normal expressions [arrow]

kou commented on code in PR #40434:
URL: https://github.com/apache/arrow/pull/40434#discussion_r1525658585


##########
cpp/src/gandiva/decimal_type_util.cc:
##########
@@ -29,8 +29,11 @@ constexpr int32_t DecimalTypeUtil::kMinAdjustedScale;
   }
 
 // Implementation of decimal rules.
+// In addition to having a precision beyond 38, it is compatible with
+// **Redshift's decimal promotion rules** if enable use_redshift_rules.

Review Comment:
   Could you use "our compute module's ... rules (which is compatible with the Redshift's ... rules)" or something to be clear?
   And could you add the URL that describes the rules?



##########
cpp/src/gandiva/decimal_type_util.cc:
##########
@@ -59,7 +62,8 @@ Status DecimalTypeUtil::GetResultType(Op op, const Decimal128TypeVector& in_type
       break;
 
     case kOpDivide:
-      result_scale = std::max(kMinAdjustedScale, s1 + p2 + 1);
+      result_scale = use_redshift_rules ? std::max(4, s1 + p2 - s2 + 1)

Review Comment:
   Can we define a named constant instead of using magic number `4` directly?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org