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/29 09:45:21 UTC

[GitHub] [arrow-rs] liukun4515 opened a new pull request, #3224: Get the round result for decimal to a decimal with smaller scale

liukun4515 opened a new pull request, #3224:
URL: https://github.com/apache/arrow-rs/pull/3224

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   https://github.com/apache/arrow-rs/pull/3139 just fix the `Safe is true`, and in [this](https://github.com/apache/arrow-rs/pull/3139) I miss the `Safe is false`.
   
   1. follow-up https://github.com/apache/arrow-rs/pull/3139
   
   2. change the ut and enhancement the macro `generate_cast_test_case` to add case with `Safe is false`.
   
   Closes #3137 
   
   # Rationale for this change
    
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking change` label.
   -->
   


-- 
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] ursabot commented on pull request #3224: Get the round result for decimal to a decimal with smaller scale

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #3224:
URL: https://github.com/apache/arrow-rs/pull/3224#issuecomment-1336185348

   Benchmark runs are scheduled for baseline = bcfbd4604c91797393163c5e941638720fa64533 and contender = cb4170b50a54c466897afc83583f01dca23544c0. cb4170b50a54c466897afc83583f01dca23544c0 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/3af742a46e18460db9d712174b21fa56...4e24727b90ce4fb6ba7c4e8ceeacac08/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/44222f97ebcb483a86ff630b467663c3...699c3b4de0c743b6a78d7f492163d753/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/4b0045f4b59641aabe743d739e9bb4bc...3c9f4a3b0cd84ffa9355601331bb94dc/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/68f9bbd6c1574a55abf67409c362e26b...fa30419d61914f5d92a44e9ac18ccb66/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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] liukun4515 commented on a diff in pull request #3224: Get the round result for decimal to a decimal with smaller scale

Posted by GitBox <gi...@apache.org>.
liukun4515 commented on code in PR #3224:
URL: https://github.com/apache/arrow-rs/pull/3224#discussion_r1034520827


##########
arrow-cast/src/cast.rs:
##########
@@ -2139,10 +2140,23 @@ fn cast_decimal_to_decimal<const BYTE_WIDTH1: usize, const BYTE_WIDTH2: usize>(
                             *output_scale,
                         ))
                     })?;
+                let half = div / 2;
+                let neg_half = -half;
 
                 array
                     .try_unary::<_, Decimal128Type, _>(|v| {
-                        v.checked_div(div).ok_or_else(|| {
+                        // cast to smaller scale, need to round the result
+                        // the div must be gt_eq 10, we don't need to check the overflow for the `div`/`mod` operation
+                        let d = v / div;

Review Comment:
   Do we need to make consistent with the usage and clear compilation result? 



-- 
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 merged pull request #3224: Get the round result for decimal to a decimal with smaller scale

Posted by GitBox <gi...@apache.org>.
tustvold merged PR #3224:
URL: https://github.com/apache/arrow-rs/pull/3224


-- 
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] liukun4515 commented on a diff in pull request #3224: Get the round result for decimal to a decimal with smaller scale

Posted by GitBox <gi...@apache.org>.
liukun4515 commented on code in PR #3224:
URL: https://github.com/apache/arrow-rs/pull/3224#discussion_r1034527678


##########
arrow-cast/src/cast.rs:
##########
@@ -3588,6 +3637,26 @@ mod tests {
                     }
                 }
             }
+
+            let cast_option = CastOptions { safe: false };

Review Comment:
   add cast with `safe is false`



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