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


##########
arrow-cast/src/cast.rs:
##########
@@ -1792,8 +1792,52 @@ pub fn cast_with_options(
                     }
                 }
             };
+            // Normalize timezone
+            let adjusted = match (from_tz, to_tz) {
+                // Only this case needs to be adjusted because we're casting 
from
+                // unknown time offset to some time offset, we want the time 
to be
+                // unchanged.
+                //
+                // i.e. Timestamp('2001-01-01T00:00', None) -> 
Timestamp('2001-01-01T00:00', '+0700')
+                (None, Some(to_tz)) => {
+                    let to_tz: Tz = to_tz.parse()?;
+                    match to_unit {
+                        TimeUnit::Second => {
+                            
adjust_timestamp_to_timezone::<TimestampSecondType>(
+                                converted,
+                                &to_tz,
+                                &cast_options,
+                            )?
+                        }
+                        TimeUnit::Millisecond => {
+                            
adjust_timestamp_to_timezone::<TimestampMillisecondType>(
+                                converted,
+                                &to_tz,
+                                &cast_options,
+                            )?
+                        }
+                        TimeUnit::Microsecond => {
+                            
adjust_timestamp_to_timezone::<TimestampMicrosecondType>(
+                                converted,
+                                &to_tz,
+                                &cast_options,
+                            )?
+                        }
+                        TimeUnit::Nanosecond => {
+                            
adjust_timestamp_to_timezone::<TimestampNanosecondType>(
+                                converted,
+                                &to_tz,
+                                &cast_options,
+                            )?
+                        }
+                    }
+                }
+                _ => {

Review Comment:
   I think we also need to handle the case of `Some(tz) to None`



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