I am connecting to AWS Athena through Mode Analytics Platform and querying a table using its Query Engine ( which is based on Presto 0.172 ). This table public.zones
AT TIME ZONE
accepts only literal or interval.
Presto 320 adds with_timezone (for timestamp
values) at_timezone (for timestamp with time zone
values) exactly for this purpose.
If you are using older Presto version (such as Athena as of this writing), you can use following workaround. You can cast your timestamp value to a varchar
, concatenate with zone and cast to timestamp with time zone
.
presto> select cast(cast(t as varchar) || ' ' || zone as timestamp with time zone)
from (values (timestamp '2017-06-01 12:34:56.789', 'US/Pacific')) x(t, zone);
_col0
---------------------------------------------
2017-06-01 12:34:56.789 America/Los_Angeles
(1 row)
(Note: tested on Presto 320. If this doesn't work on Athena yet, let me know.)