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

   - Existing string to decimal cast uses parse_string_to_decimal_native
   - parse_string_to_decimal_native does not have support for e-notation
   - parse_string_to_decimal_native does rounding at scale, not truncate
   - parse_decimal an existing method has e-notation support and use elsewhere 
like arrow-csv, arrow-json.
   - parse_decimal tests with scale 0, fails as shown below 
   ```rust
   assert_eq!(
               parse_decimal::<Decimal128Type>("123.45", 38, 0)?,
               123_i128
           );
   
   assertion `left == right` failed
   Left:  12345
   Right: 123
   
   ```
    - existing test using parse_decimal native works
    
    ```rust
   assert_eq!(
               parse_string_to_decimal_native::<Decimal128Type>("123.45", 0)?,
               123_i128
           );
   ```
   
   -  pars_decimal truncates as defualt behavior, 
parse_string_to_decimal_native does rounding, hence read from json, or csv of a 
decimal has truncated value but result of a cast operation has rounded value.
   
   ```rust
   assert_eq!(
               parse_decimal::<Decimal128Type>("123.4567891", 38, 5)?,
               12345679_i128
           );
   
   assertion `left == right` failed
     left: 12345678
    right: 12345679
   
   ```
   vs
   
   ```
   assert_eq!(
               parse_string_to_decimal_native::<Decimal128Type>("123.4567891", 
5)?,
               12345679_i128
           );
   
   works fine..
   ``` 
   
   This issue was raised as part of investigation to fix this [datafusion 
issue] (https://github.com/apache/datafusion/issues/10315)
   
   if parse_decimal add rounding logic and fix the issue with scale=0, parse 
decimal can be used for string to decimal cast, thereby getting the scientific 
notation along with it.
   
   
   
   <!--
   A clear and concise description of what the problem is. Ex. I'm always 
frustrated when [...] 
   (This section helps Arrow developers understand the context and *why* for 
this feature, in addition to  the *what*)
   -->
   
   **Describe the solution you'd like**
   <!--
   A clear and concise description of what you want to happen.
   -->
   
   **Describe alternatives you've considered**
   <!--
   A clear and concise description of any alternative solutions or features 
you've considered.
   -->
   
   **Additional context**
   <!--
   Add any other context or screenshots about the feature request 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