jorgecarleitao commented on a change in pull request #8486:
URL: https://github.com/apache/arrow/pull/8486#discussion_r512143167



##########
File path: rust/arrow/src/array/array.rs
##########
@@ -1540,22 +1540,38 @@ impl<OffsetSize: StringOffsetSizeTrait> 
GenericStringArray<OffsetSize> {
             offsets.push(length_so_far);
             values.extend_from_slice(s.as_bytes());
         }
-        let array_data = ArrayData::builder(data_type)
+        let array_data = ArrayData::builder(OffsetSize::DATA_TYPE)
             .len(v.len())
             .add_buffer(Buffer::from(offsets.to_byte_slice()))
             .add_buffer(Buffer::from(&values[..]))
             .build();
         Self::from(array_data)
     }
 
-    pub(crate) fn from_opt_vec(v: Vec<Option<&str>>, data_type: DataType) -> 
Self {
-        let mut offsets = Vec::with_capacity(v.len() + 1);
+    pub(crate) fn from_opt_vec(v: Vec<Option<&str>>) -> Self {
+        let iter = v.iter().map(|e| e.map(|e| e.to_string()));
+        GenericStringArray::from_iter(iter)
+    }
+}
+
+impl<'a, Ptr, OffsetSize: StringOffsetSizeTrait> FromIterator<Ptr>

Review comment:
       I see. I have no strong feelings about it, I just think that explicit is 
better than implicit, and `P` or `OS` forces the reader to go to the `where` 
clause to understand what they mean. OTOH, generics are generics, and also rust 
seems to prefer one-letter generic types.
   
   I will leave it like this just because the rest of the code base around 
offsets is like this.




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

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


Reply via email to