viirya commented on code in PR #3115:
URL: https://github.com/apache/arrow-rs/pull/3115#discussion_r1023525036


##########
arrow-array/src/array/primitive_array.rs:
##########
@@ -1939,4 +2032,52 @@ mod tests {
 
         array.value(4);
     }
+
+    #[test]
+    fn test_into_builder() {
+        let array: Int32Array = vec![1, 2, 3].into_iter().map(Some).collect();
+
+        let boxed: ArrayRef = Arc::new(array);
+        let col: Int32Array = downcast_array(&boxed);
+        drop(boxed);
+
+        let mut builder = col.into_builder().unwrap();
+
+        builder.append_value(4);
+        builder.append_null();
+        builder.append_value(2);
+
+        let expected: Int32Array = vec![Some(4), None, 
Some(2)].into_iter().collect();

Review Comment:
   Yea, currently the returned builder sets length to `0` so it will overwrite 
the existing values. Per the latest suggestion, it makes more sense to have the 
same length as the array. And we can ask for mutable slice if we want to mutate 
the existing values.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to