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/21 01:53:17 UTC

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

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


##########
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:
   Tbh I wonder if we should just deprecate these APIs now? What do people think?



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