zeroshade commented on code in PR #43957:
URL: https://github.com/apache/arrow/pull/43957#discussion_r1761361053
##########
cpp/src/arrow/type.cc:
##########
@@ -480,7 +494,7 @@ Result<std::shared_ptr<DataType>> MaybeMergeNumericTypes(
ARROW_ASSIGN_OR_RAISE(const int32_t precision,
MaxDecimalDigitsForInteger(other_type->id()));
ARROW_ASSIGN_OR_RAISE(const auto promoted_decimal,
- DecimalType::Make(promoted_type->id(), precision,
0));
+ DecimalType::Make(promoted_type->id(), precision -
1, 0));
Review Comment:
The values we use for `MaxDecimalDigitsForInteger` is actually 1 +
numeric_limits<T>::digits10 (i.e. for int32/uint32 we return 10 instead of 9,
for int64 we return 19 instead of 18). As such we were passing a precision that
was higher than the maximum precision allowed for Decimal32 and Decimal64 here
(9 and 18 respectively).
it felt safer to me to put the -1 here than to change the value returned in
`MaxDecimalDigitsForInteger` (which is used elsewhere and caused other
complications in tests)
--
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]