zeroshade commented on code in PR #43957:
URL: https://github.com/apache/arrow/pull/43957#discussion_r1761350590


##########
cpp/src/arrow/testing/random.cc:
##########
@@ -343,8 +343,119 @@ struct DecimalGenerator {
   }
 };
 
+template <>
+struct DecimalGenerator<Decimal32Type> {
+  using DecimalBuilderType = typename TypeTraits<Decimal32Type>::BuilderType;
+  using DecimalValue = typename DecimalBuilderType::ValueType;
+
+  std::shared_ptr<DataType> type_;
+  RandomArrayGenerator* rng_;
+
+  static int32_t MaxDecimalInteger(int32_t digits) {
+    return static_cast<int32_t>(std::ceil(std::pow(10.0, digits))) - 1;
+  }
+
+  std::shared_ptr<Array> MakeRandomArray(int64_t size, double null_probability,
+                                         int64_t alignment, MemoryPool* 
memory_pool) {
+    static constexpr int32_t kMaxDigitsInInteger = 9;
+    static constexpr int kNumIntegers = Decimal32Type::kByteWidth / 4;
+    static_assert(
+        kNumIntegers == (Decimal32Type::kMaxPrecision + kMaxDigitsInInteger - 
1) /
+                            (kMaxDigitsInInteger + 1),
+        "inconsistent decimal metadata: kMaxPrecision doesn't match 
kByteWidth");
+
+    // First generate separate random values for individual components:
+    // boolean sign (including null-ness), and uint64 "digits" in big endian 
order.

Review Comment:
   you're right, that comment is for the decimal64/128/256 not for 32, i'll 
remove 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]

Reply via email to