HaoYang670 opened a new issue, #2362:
URL: https://github.com/apache/arrow-rs/issues/2362

   **Describe the bug**
   Also related to the Decimal. Currently, the constructor 
DataType::Decimal128/256(precision: usize, scale: usize) is unsound, because 
users can put any value in it. Also this leads to 2 kinds of bug in the code:
       1. forget to check the value of  precision  and scale
       2. redundant checking.
   
   **Expected behavior**
   I’d like to eliminate this unsoundness by using stronger type system, which 
means create a new type for precision and scale:
   ```
   struct DecimalInfo{
       precision: usize,
       scale: usize,
   }
   
   impl DecimalInfo{
       fn new(precision: usize, scale: usize) -> Self {
           assert (precision <= max_precision);
           assert (scale <= max_precision);
           assert (scale <= precision);
           Self {precision, scale}
       }
       fn get_precision {...}
       fn get_scale {...}
       fn set_scale {...}
       fn set_precision {...}
   }
   
   enum DataType {
       Decimal128(DecimalInfo),
       ...
   }
   ```
   **Additional context**
   <!--
   Add any other context about the problem here.
   -->


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