You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/02 00:32:20 UTC

[GitHub] [arrow-rs] andygrove opened a new issue, #2997: I would like to round rather than trucate when casting f64 to decimal

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

   **Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
   <!--
   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*)
   -->
   
   If I convert `0.06999999` to a decimal with scale 2 I would like to get `0.07` rather than `0.06`
   
   ```rust
       #[test]
       #[cfg(not(feature = "force_validate"))]
       fn test_cast_f64_to_decimal128() {
           let decimal_type = DataType::Decimal128(18, 2);
           let array = Float64Array::from(vec![
               Some(0.0699999999),
           ]);
           let array = Arc::new(array) as ArrayRef;
           generate_cast_test_case!(
               &array,
               Decimal128Array,
               &decimal_type,
               vec![
                   Some(7_i128),
               ]
           );
       }
   ```
   
   This fails with:
   
   ```
   Left:  6
   Right: 7
   ```
   
   **Describe the solution you'd like**
   <!--
   A clear and concise description of what you want to happen.
   -->
   
   Provide an option for round vs truncate?
   Default to round?
   
   **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: github-unsubscribe@arrow.apache.org.apache.org

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


[GitHub] [arrow-rs] alamb commented on issue #2997: I would like to round rather than truncate when casting f64 to decimal

Posted by GitBox <gi...@apache.org>.
alamb commented on issue #2997:
URL: https://github.com/apache/arrow-rs/issues/2997#issuecomment-1312141203

   `label_issue.py` automatically added labels {'arrow'} from #3000


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


[GitHub] [arrow-rs] andygrove commented on issue #2997: I would like to round rather than trucate when casting f64 to decimal

Posted by GitBox <gi...@apache.org>.
andygrove commented on issue #2997:
URL: https://github.com/apache/arrow-rs/issues/2997#issuecomment-1299394038

   @liukun4515 @viirya fyi 


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


[GitHub] [arrow-rs] tustvold closed issue #2997: I would like to round rather than truncate when casting f64 to decimal

Posted by GitBox <gi...@apache.org>.
tustvold closed issue #2997: I would like to round rather than truncate when casting f64 to decimal
URL: https://github.com/apache/arrow-rs/issues/2997


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