[ 
https://issues.apache.org/jira/browse/ARROW-13247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17373366#comment-17373366
 ] 

Joris Van den Bossche commented on ARROW-13247:
-----------------------------------------------

Yeah, I was just typing a comment that this could also be done with Cast, and 
that this actually already works today:

{code}
In [5]: pa.array([1, 2, 3], pa.timestamp("us", 
"Europe/Brussels")).cast(pa.timestamp("us", "Europe/London"))
Out[5]: 
<pyarrow.lib.TimestampArray object at 0x7f7558ca3340>
[
  1970-01-01 00:00:00.000001,
  1970-01-01 00:00:00.000002,
  1970-01-01 00:00:00.000003
]

In [6]: _.type
Out[6]: TimestampType(timestamp[us, tz=Europe/London])
{code}

However, a drawback of cast is that you need to know/specify the unit of your 
input timestamp (assuming you typically want to preserve the unit for this 
operation), which makes this more verbose to express, and difficult to do in a 
generic query execution / expression interface where you might not necessarily 
know the exact unit when defining the operation.

> [C++] Kernel to convert timestamp with timezone to another timezone 
> (metadata-only change)
> ------------------------------------------------------------------------------------------
>
>                 Key: ARROW-13247
>                 URL: https://issues.apache.org/jira/browse/ARROW-13247
>             Project: Apache Arrow
>          Issue Type: Improvement
>            Reporter: Joris Van den Bossche
>            Priority: Major
>              Labels: timestamp, timezone
>
> Related to ARROW-13033, but assuming you already have a tz-aware "timestamp 
> with timezone" type, and you want to change it to have another timezone. 
> In practice, this is a trivial, metadata-only change since in both cases the 
> actual values are stored in UTC, and so it's only changing the tz 
> parametrization of the timestamp type. But, for convenience, I think it would 
> still be useful to have it as an actual kernel to easily integrate this 
> operation in this framework.
> References: 
> [tz_convert|https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DatetimeIndex.tz_convert.html]
>  in pandas, or 
> [with_tz|https://lubridate.tidyverse.org/reference/with_tz.html] in R's 
> lubridate package,{{withZone}} in Joda or 
> [withZoneSameInstant|https://docs.oracle.com/javase/8/docs/api/java/time/ZonedDateTime.html#withZoneSameInstant-java.time.ZoneId-]
>  in Java



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to