sunchao commented on code in PR #2608:
URL: https://github.com/apache/arrow-rs/pull/2608#discussion_r959969219


##########
arrow/src/compute/kernels/temporal.rs:
##########
@@ -28,33 +28,33 @@ use chrono::format::{parse, Parsed};
 use chrono::FixedOffset;
 
 macro_rules! extract_component_from_array {
-    ($array:ident, $builder:ident, $extract_fn:ident, $using:ident) => {
+    ($array:ident, $builder:ident, $extract_fn:ident, $using:ident, 
$convert:expr) => {

Review Comment:
   why we need the `$convert`?



##########
arrow/src/compute/kernels/mod.rs:
##########
@@ -35,5 +35,6 @@ pub mod sort;
 pub mod substring;
 pub mod take;
 pub mod temporal;
+// pub(crate) use temporal::extract_component_from_array;

Review Comment:
   what is this for?



##########
arrow/src/compute/kernels/cast.rs:
##########
@@ -1482,25 +1487,35 @@ where
 }
 
 /// Cast timestamp types to Utf8/LargeUtf8
-fn cast_timestamp_to_string<T, OffsetSize>(array: &ArrayRef) -> 
Result<ArrayRef>
+fn cast_timestamp_to_string<T, OffsetSize>(
+    array: &ArrayRef,
+    tz: &Option<String>,
+) -> Result<ArrayRef>
 where
     T: ArrowTemporalType + ArrowNumericType,
     i64: From<<T as ArrowPrimitiveType>::Native>,
     OffsetSize: OffsetSizeTrait,
 {
     let array = array.as_any().downcast_ref::<PrimitiveArray<T>>().unwrap();
 
-    Ok(Arc::new(
-        (0..array.len())
-            .map(|ix| {
-                if array.is_null(ix) {
-                    None
-                } else {
-                    array.value_as_datetime(ix).map(|v| v.to_string())
-                }
-            })
-            .collect::<GenericStringArray<OffsetSize>>(),
-    ))
+    let mut builder = GenericStringBuilder::<OffsetSize>::new();
+
+    if let Some(tz) = tz {
+        let mut scratch = Parsed::new();
+        extract_component_from_array!(

Review Comment:
   it's not too obvious to see what this is doing, maybe add some comments?



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