trino: Provide AT ZONE-equivalent functions where zone name is not constant

~make at_timezone it public (see @dain 's https://github.com/prestodb/presto/issues/5162#issuecomment-434127569) and add documentation~

This is required to perform AT TIME ZONE conversion when zone is not a constant

See https://github.com/prestosql/presto/issues/135#issuecomment-466559709 comment below for what should be implemented in this issue.

Ref https://github.com/prestodb/presto/issues/5162

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 23 (21 by maintainers)

Commits related to this issue

Most upvoted comments

There are a bunch of references to this function in stackoverflow, so at the very least we would need to deprecate the old name.

Summing up:

what we (possibly?) need are these behaviors:

  1. Make a TIMESTAMP WITH TIME ZONE from a TIMESTAMP and a timezone. function(ts::TIMESTAMP, timezone::VARCHAR) :: TIMESTAMP WITH TIME ZONE
  2. Change the timezone component of a TIMESTAMP WITH TIME ZONE while preserving the instant in time. function(ts:TIMESTAMP WITH TIME ZONE, target_timezone::VARCHAR) :: TIMESTAMP WITH TIME ZONE
  3. Change the timezone offset associated with a TIMESTAMP WITH TIMEZONE while preserving the local timestamp. function(ts:TIMESTAMP WITH TIME ZONE, target_timezone::VARCHAR) :: TIMESTAMP WITH TIME ZONE
  • with_timezone for (1)
  • at_timezone for (2)
  • currently no function for (3)

what about at_timezone_keep_local or at_timezone_same_local for 3.?

I’d say, let’s leave that one out. It seems an uncommon use case with a reasonable workaround. If there’s demand later, we can consider adding such a function.