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/24 19:17:59 UTC

[GitHub] [arrow-rs] alamb commented on a diff in pull request #2906: Simplify TimestampArray from_vec with timezone

alamb commented on code in PR #2906:
URL: https://github.com/apache/arrow-rs/pull/2906#discussion_r1003664992


##########
arrow-array/src/array/primitive_array.rs:
##########
@@ -761,13 +761,19 @@ def_numeric_from_vec!(TimestampNanosecondType);
 
 impl<T: ArrowTimestampType> PrimitiveArray<T> {
     /// Construct a timestamp array from a vec of i64 values and an optional timezone
-    pub fn from_vec(data: Vec<i64>, timezone: Option<String>) -> Self {
-        let array_data =
-            ArrayData::builder(DataType::Timestamp(T::get_time_unit(), timezone))
-                .len(data.len())
-                .add_buffer(Buffer::from_slice_ref(&data));
-        let array_data = unsafe { array_data.build_unchecked() };
-        PrimitiveArray::from(array_data)
+    pub fn from_vec(data: Vec<i64>, timezone: Option<String>) -> Self
+    where
+        Self: From<Vec<i64>>,
+    {
+        Self::from(data).with_timezone_opt(timezone)

Review Comment:
   If you mean deprecate the `from_vec` API now that we have `with_timezone_opt` it seems like a good idea to me



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