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 2021/09/20 09:22:22 UTC

[GitHub] [arrow-rs] sum12 commented on a change in pull request #771: handle tz while extractiing second/minute/hour from Timestamp* arrays

sum12 commented on a change in pull request #771:
URL: https://github.com/apache/arrow-rs/pull/771#discussion_r712003289



##########
File path: arrow/src/compute/kernels/temporal.rs
##########
@@ -22,6 +22,53 @@ use chrono::{Datelike, Timelike};
 use crate::array::*;
 use crate::datatypes::*;
 use crate::error::{ArrowError, Result};
+
+use chrono::format::strftime::StrftimeItems;
+use chrono::format::{parse, Parsed};
+
+macro_rules! extract_component_from_array {
+    ($array:ident, $builder:ident, $extract_fn:ident, $using:ident) => {
+        for i in 0..$array.len() {
+            if $array.is_null(i) {
+                $builder.append_null()?;
+            } else {
+                match $array.$using(i) {
+                    Some(dt) => $builder.append_value(dt.$extract_fn() as i32)?,
+                    None => $builder.append_null()?,
+                }
+            }
+        }
+    };
+    ($array:ident, $builder:ident, $extract_fn:ident, $using:ident, $tz:ident, $parsed:ident) => {
+        match parse(&mut $parsed, $tz, StrftimeItems::new("%z")) {

Review comment:
       since `parse` from chrono is being used. The colon (`:`) become [optional]( https://docs.rs/chrono/0.4.19/src/chrono/format/parse.rs.html#414) and this differs from the schema.  If needed check can be added here.




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