tustvold commented on code in PR #1964:
URL: https://github.com/apache/arrow-rs/pull/1964#discussion_r909524690


##########
arrow/src/array/array_binary.rs:
##########
@@ -831,22 +831,26 @@ impl DecimalArray {
         precision: usize,
         scale: usize,
     ) -> Self {
+        let child_data = &v.data_ref().child_data()[0];
         assert_eq!(
-            v.data_ref().child_data()[0].child_data().len(),
+            child_data.child_data().len(),
             0,
             "DecimalArray can only be created from list array of u8 values \
              (i.e. FixedSizeList<PrimitiveArray<u8>>)."
         );
         assert_eq!(
-            v.data_ref().child_data()[0].data_type(),
+            child_data.data_type(),
             &DataType::UInt8,
             "DecimalArray can only be created from FixedSizeList<u8> arrays, 
mismatched data types."
         );
 
+        let list_offset = v.offset();
+        let child_offset = child_data.offset();
         let builder = ArrayData::builder(DataType::Decimal(precision, scale))
             .len(v.len())
-            .add_buffer(v.data_ref().child_data()[0].buffers()[0].clone())
-            .null_bit_buffer(v.data_ref().null_buffer().cloned());
+            
.add_buffer(v.data_ref().child_data()[0].buffers()[0].slice(child_offset))

Review Comment:
   ```suggestion
               .add_buffer(child_data.buffers()[0].slice(child_offset))
   ```



##########
arrow/src/array/array_binary.rs:
##########
@@ -831,22 +831,26 @@ impl DecimalArray {
         precision: usize,
         scale: usize,
     ) -> Self {
+        let child_data = &v.data_ref().child_data()[0];

Review Comment:
   Somewhat tangential to this PR, but what happens to the child data's null 
buffer? Perhaps worth a docstring saying it is ignored?



-- 
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-unsubscr...@arrow.apache.org

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

Reply via email to