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/10/13 21:50:45 UTC

[GitHub] [arrow-rs] tustvold opened a new pull request, #2865: Decimal cleanup (#2637)

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

   # 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.
   -->
   
   Part of #2637
   
   # 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.
   -->
   
   Follow on to #2857 that takes the opportunity to perform some further cleanups
   
   # 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.
   -->
   
   Makes some APIs infallible, and removes the no longer needed `Decimal` abstraction
   
   # Are there any user-facing changes?
   
   No, #2857 hasn't been released yet
   
   <!--
   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.
   -->
   
   FYI @alamb it would be good for some version of this to make the next release if possible, to avoid API churn
   


-- 
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 #2865: Decimal cleanup (#2637)

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

   Benchmark runs are scheduled for baseline = d7f994c2af59653db5a18c52920f0b5dbd27ff6f and contender = d67d5fb0086ee5a18bf3a148c874ccb11533044d. d67d5fb0086ee5a18bf3a148c874ccb11533044d 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/ff6691cf3576497dafbb986978b2e4f8...952778c7308c478188675d57e2d0e964/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/4aa038e80fbd4b279d960a39b9e8a0bb...d808d965decd4620b0f5a26e89d01712/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/31e73275382a4cd4bffae9624eba029f...385f91dde91a4af882db02987c7fd74a/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/36dd868436ca4b61baae61fba9e478c1...d6221309d81d454eb10841d2180e8fe3/)
   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] tustvold commented on a diff in pull request #2865: Decimal cleanup (#2637)

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


##########
arrow-array/src/types.rs:
##########
@@ -569,6 +565,26 @@ impl ArrowPrimitiveType for Decimal256Type {
     const DATA_TYPE: DataType = <Self as DecimalType>::DEFAULT_TYPE;
 }
 
+fn format_decimal_str(value_str: &str, precision: usize, scale: usize) -> String {

Review Comment:
   This is based on the logic from `Decimal::to_string`, adding this allows removing the now unnecessary `Decimal` construct.



-- 
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 #2865: Decimal cleanup (#2637)

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


-- 
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 commented on a diff in pull request #2865: Decimal cleanup (#2637)

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


##########
arrow-array/src/array/primitive_array.rs:
##########
@@ -917,67 +916,62 @@ impl<T: DecimalType + ArrowPrimitiveType> PrimitiveArray<T> {
         })
     }
 
-    pub fn value_as_string(&self, row: usize) -> Result<String, ArrowError> {
-        let p = self.precision()?;
-        let s = self.scale()?;
-        Ok(Decimal::<T>::new(p, s, &T::to_native(self.value(row))).to_string())
+    /// Returns [`Self::value`] formatted as a string
+    pub fn value_as_string(&self, row: usize) -> String {
+        T::format_decimal(self.value(row), self.precision(), self.scale())
     }
 
-    pub fn precision(&self) -> Result<u8, ArrowError> {
+    /// Returns the decimal precision of this array
+    pub fn precision(&self) -> u8 {

Review Comment:
   These methods can be made infallible as the error case is actually unreachable, as of #2835 we consistently verify the data type



-- 
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 commented on a diff in pull request #2865: Decimal cleanup (#2637)

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


##########
arrow-array/src/array/primitive_array.rs:
##########
@@ -1564,8 +1558,8 @@ mod tests {
             .build()
             .unwrap();
         let decimal_array = Decimal128Array::from(array_data);
-        assert_eq!(8_887_000_000_i128, decimal_array.value(0).into());
-        assert_eq!(-8_887_000_000_i128, decimal_array.value(1).into());
+        assert_eq!(8_887_000_000_i128, decimal_array.value(0));

Review Comment:
   These `Into::into` conversions are redundant and were making clippy unhappy



-- 
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 commented on a diff in pull request #2865: Decimal cleanup (#2637)

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


##########
.github/workflows/arrow.yml:
##########
@@ -186,6 +186,14 @@ jobs:
       - name: Setup Clippy
         run: |
           rustup component add clippy
-      - name: Run clippy
+      - name: Clippy arrow-buffer with all features

Review Comment:
   This was a consequence of #2594 and was preventing linting of the split apart crates



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