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/07/25 07:43:09 UTC

[GitHub] [arrow-rs] liukun4515 opened a new pull request, #2160: parquet reader: support read decimal from parquet binary type

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

   # 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.
   -->
   
   Closes #2159
   
   # 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] alamb commented on a diff in pull request #2160: parquet reader: Support reading decimals from parquet `BYTE_ARRAY` type

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


##########
parquet/src/arrow/array_reader/builder.rs:
##########
@@ -233,6 +225,18 @@ fn build_primitive_reader(
                 column_desc,
                 arrow_type,
             ),
+            Some(DataType::Decimal(precision, scale)) => {
+                // read decimal data from parquet binary physical type
+                let convert = DecimalByteArrayConvert::new(DecimalArrayConverter::new(precision as i32, scale as i32));

Review Comment:
   Is this the core change?
   
    (namely to support reading arrow `DataType::Decimal` from parquet `BYTE_ARRAY` type where previously the code only supported `DataType::Decimal` in `FIXED_LEN_BYTE_ARRAY fields)?



##########
parquet/src/arrow/schema.rs:
##########
@@ -531,6 +531,32 @@ mod tests {
         assert_eq!(&arrow_fields, converted_arrow_schema.fields());
     }
 
+    #[test]
+    fn test_decimal_fields() {
+        let message_type = "
+        message test_schema {
+                    REQUIRED INT32 decimal1 (DECIMAL(4,2));
+                    REQUIRED INT64 decimal2 (DECIMAL(12,2));
+                    REQUIRED FIXED_LEN_BYTE_ARRAY (16) decimal3 (DECIMAL(30,2));
+                    REQUIRED BYTE_ARRAY decimal4 (DECIMAL(33,2));
+        }
+        ";
+
+        let parquet_group_type = parse_message_type(message_type).unwrap();
+
+        let parquet_schema = SchemaDescriptor::new(Arc::new(parquet_group_type));
+        let converted_arrow_schema =
+            parquet_to_arrow_schema(&parquet_schema, None).unwrap();
+
+        let arrow_fields = vec![
+            Field::new("decimal1", DataType::Decimal(4,2), false),
+            Field::new("decimal2", DataType::Decimal(12,2), false),
+            Field::new("decimal3", DataType::Decimal(30,2), false),
+            Field::new("decimal4", DataType::Decimal(33,2), false),

Review Comment:
   this would this have previously failed?



-- 
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] viirya commented on a diff in pull request #2160: parquet reader: Support reading decimals from parquet `BYTE_ARRAY` type

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


##########
parquet/src/arrow/schema.rs:
##########
@@ -531,6 +531,32 @@ mod tests {
         assert_eq!(&arrow_fields, converted_arrow_schema.fields());
     }
 
+    #[test]
+    fn test_decimal_fields() {
+        let message_type = "
+        message test_schema {
+                    REQUIRED INT32 decimal1 (DECIMAL(4,2));
+                    REQUIRED INT64 decimal2 (DECIMAL(12,2));
+                    REQUIRED FIXED_LEN_BYTE_ARRAY (16) decimal3 (DECIMAL(30,2));
+                    REQUIRED BYTE_ARRAY decimal4 (DECIMAL(33,2));
+        }
+        ";
+
+        let parquet_group_type = parse_message_type(message_type).unwrap();
+
+        let parquet_schema = SchemaDescriptor::new(Arc::new(parquet_group_type));
+        let converted_arrow_schema =
+            parquet_to_arrow_schema(&parquet_schema, None).unwrap();
+
+        let arrow_fields = vec![
+            Field::new("decimal1", DataType::Decimal(4,2), false),
+            Field::new("decimal2", DataType::Decimal(12,2), false),
+            Field::new("decimal3", DataType::Decimal(30,2), false),
+            Field::new("decimal4", DataType::Decimal(33,2), false),

Review Comment:
   Yea, this has previously failed as I just ran this test to confirm.
   
   ```
   ---- arrow::schema::tests::test_decimal_fields stdout ----
   thread 'arrow::schema::tests::test_decimal_fields' panicked at 'called `Result::unwrap()` on an `Err` value: ArrowError("Unable to convert parquet BYTE_ARRAY logical type Some(Decimal { scale: 2, precision: 33 }) or converted type DECIMAL")', parquet/src/arrow/schema.rs:1734:60
   ```



-- 
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 merged pull request #2160: parquet reader: Support reading decimals from parquet `BYTE_ARRAY` type

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


-- 
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] codecov-commenter commented on pull request #2160: parquet reader: support read decimal from parquet binary type

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #2160:
URL: https://github.com/apache/arrow-rs/pull/2160#issuecomment-1193744582

   # [Codecov](https://codecov.io/gh/apache/arrow-rs/pull/2160?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2160](https://codecov.io/gh/apache/arrow-rs/pull/2160?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (c7268f4) into [master](https://codecov.io/gh/apache/arrow-rs/commit/1621c713d724b0cd4aabccfa3243714789283df5?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (1621c71) will **decrease** coverage by `0.01%`.
   > The diff coverage is `100.00%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #2160      +/-   ##
   ==========================================
   - Coverage   82.85%   82.83%   -0.02%     
   ==========================================
     Files         237      237              
     Lines       61381    61461      +80     
   ==========================================
   + Hits        50856    50913      +57     
   - Misses      10525    10548      +23     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/arrow-rs/pull/2160?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [parquet/src/arrow/array\_reader/builder.rs](https://codecov.io/gh/apache/arrow-rs/pull/2160/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvYXJyb3cvYXJyYXlfcmVhZGVyL2J1aWxkZXIucnM=) | `93.46% <100.00%> (+0.31%)` | :arrow_up: |
   | [parquet/src/arrow/arrow\_reader.rs](https://codecov.io/gh/apache/arrow-rs/pull/2160/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvYXJyb3cvYXJyb3dfcmVhZGVyLnJz) | `92.81% <100.00%> (+0.05%)` | :arrow_up: |
   | [parquet/src/arrow/buffer/converter.rs](https://codecov.io/gh/apache/arrow-rs/pull/2160/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvYXJyb3cvYnVmZmVyL2NvbnZlcnRlci5ycw==) | `84.26% <100.00%> (+0.93%)` | :arrow_up: |
   | [parquet/src/arrow/schema.rs](https://codecov.io/gh/apache/arrow-rs/pull/2160/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvYXJyb3cvc2NoZW1hLnJz) | `96.93% <100.00%> (+0.05%)` | :arrow_up: |
   | [parquet/src/arrow/schema/primitive.rs](https://codecov.io/gh/apache/arrow-rs/pull/2160/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvYXJyb3cvc2NoZW1hL3ByaW1pdGl2ZS5ycw==) | `80.86% <100.00%> (+3.87%)` | :arrow_up: |
   | [parquet/src/basic.rs](https://codecov.io/gh/apache/arrow-rs/pull/2160/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvYmFzaWMucnM=) | `91.56% <100.00%> (+0.06%)` | :arrow_up: |
   | [arrow/src/array/iterator.rs](https://codecov.io/gh/apache/arrow-rs/pull/2160/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2l0ZXJhdG9yLnJz) | `86.45% <0.00%> (-13.55%)` | :arrow_down: |
   | [arrow/src/util/decimal.rs](https://codecov.io/gh/apache/arrow-rs/pull/2160/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL3V0aWwvZGVjaW1hbC5ycw==) | `86.92% <0.00%> (-4.59%)` | :arrow_down: |
   | [arrow/src/array/array\_decimal.rs](https://codecov.io/gh/apache/arrow-rs/pull/2160/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2FycmF5X2RlY2ltYWwucnM=) | `90.32% <0.00%> (-0.72%)` | :arrow_down: |
   | [arrow/src/datatypes/datatype.rs](https://codecov.io/gh/apache/arrow-rs/pull/2160/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2RhdGF0eXBlcy9kYXRhdHlwZS5ycw==) | `62.69% <0.00%> (-0.32%)` | :arrow_down: |
   | ... and [3 more](https://codecov.io/gh/apache/arrow-rs/pull/2160/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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] viirya commented on a diff in pull request #2160: parquet reader: Support reading decimals from parquet `BYTE_ARRAY` type

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


##########
parquet/src/arrow/array_reader/builder.rs:
##########
@@ -233,6 +225,18 @@ fn build_primitive_reader(
                 column_desc,
                 arrow_type,
             ),
+            Some(DataType::Decimal(precision, scale)) => {
+                // read decimal data from parquet binary physical type
+                let convert = DecimalByteArrayConvert::new(DecimalArrayConverter::new(precision as i32, scale as i32));
+                Ok(Box::new(
+                    ComplexObjectArrayReader::<ByteArrayType,DecimalByteArrayConvert>::new(

Review Comment:
   style?
   
   ```suggestion
                       ComplexObjectArrayReader::<ByteArrayType, DecimalByteArrayConvert>::new(
   ```



-- 
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 #2160: parquet reader: Support reading decimals from parquet `BYTE_ARRAY` type

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


##########
parquet/src/arrow/array_reader/builder.rs:
##########
@@ -233,6 +225,18 @@ fn build_primitive_reader(
                 column_desc,
                 arrow_type,
             ),
+            Some(DataType::Decimal(precision, scale)) => {
+                // read decimal data from parquet binary physical type
+                let convert = DecimalByteArrayConvert::new(DecimalArrayConverter::new(precision as i32, scale as i32));
+                Ok(Box::new(
+                    ComplexObjectArrayReader::<ByteArrayType,DecimalByteArrayConvert>::new(

Review Comment:
   The code has been formatted.



-- 
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 #2160: parquet reader: Support reading decimals from parquet `BYTE_ARRAY` type

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


##########
parquet/src/arrow/array_reader/builder.rs:
##########
@@ -233,6 +225,18 @@ fn build_primitive_reader(
                 column_desc,
                 arrow_type,
             ),
+            Some(DataType::Decimal(precision, scale)) => {
+                // read decimal data from parquet binary physical type
+                let convert = DecimalByteArrayConvert::new(DecimalArrayConverter::new(precision as i32, scale as i32));

Review Comment:
   Yes.
   previously, decimal just can be read from `int32,int64,byte_array`, but in the definition of parquet decimal can be read from `int32,int64,byte_array,fixed_length_byte_array`.



-- 
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] alamb commented on pull request #2160: parquet reader: Support reading decimals from parquet `BYTE_ARRAY` type

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

   Other reviewers might find the context on https://github.com/apache/arrow-datafusion/pull/2960/files#r928343239 helpful


-- 
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 #2160: parquet reader: Support reading decimals from parquet `BYTE_ARRAY` type

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

   Benchmark runs are scheduled for baseline = ec3530da596a4535097d9d734b23291153f058f7 and contender = 37dd03756953d92bd303549fb0f7610a6d3c5c56. 37dd03756953d92bd303549fb0f7610a6d3c5c56 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/4d0e683656814e19ae9f953db3ad6c25...95e7aaab28714291893dd55f997f02b2/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/fddf7091e5eb4065a1d1d8d3200f9330...18f5d9cc417c448597f691314d8444fa/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/b8281668cd1a419ab4419d92500921f2...669b9c15dba24f2fb14268bee5436826/)
   [Skipped :warning: Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/865f5d97e0ab4e318ccecf531cda8e9e...5107de1fc90c4e03b42b3b4fc56353fb/)
   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 #2160: parquet reader: support read decimal from parquet binary type

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


##########
parquet/src/arrow/buffer/converter.rs:
##########
@@ -76,16 +76,6 @@ impl DecimalArrayConverter {
     pub fn new(precision: i32, scale: i32) -> Self {
         Self { precision, scale }
     }
-
-    fn from_bytes_to_i128(b: &[u8]) -> i128 {

Review Comment:
   move this method out and as a public method for this mod



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