Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix format_datetime to used linked TimeZone names #11337

Closed

Conversation

kevinwilfong
Copy link
Contributor

Summary:
JODA has this concept of linked Time Zones where given a particular time zone ID, it
will write out a different time zone ID when formatting a timestamp as a string (I
suspect this is for historical reasons).

More information is available about this here https://github.com/JodaOrg/global-tz

This diff adds a script to parse the file JODA uses to get these links and turn it into a
static map. I've done this for the file in the version of JODA Presto Java currently uses
(there have been significant updates in more recent versions). Note that the file
guarantees there are no transitive links so we don't need to handle that case.

I then updated the format_datetime UDF to use this mapping for the ZZZ (or more)
pattern. It will use the linked time zone ID in place of the time zone ID if one is
available.

This is also fixes casting TimestampWithTimeZone to Varchar which uses the same
code path.

Differential Revision: D64870014

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 23, 2024
Copy link

netlify bot commented Oct 23, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 547c86a
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/672124ff76ba3600088f4656

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D64870014

Copy link
Contributor

@xiaoxmeng xiaoxmeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinwilfong thanks!

Kevin Wilfong and others added 5 commits October 28, 2024 10:00
…or#11283)

Summary:
Pull Request resolved: facebookincubator#11283

The format_datetime currently outptus the time zone id if for 3 or fewer 'z' characters
in the format string.  However, the JODA library, which this is based on, does this for
3 or more 'Z' characters.

https://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html

This diff fixes this, as well as adds support for a single 'Z' (which outputs the same
thing as 'ZZ' just without the colon).  So 'Z' is fully supported for any number of
characters.

Differential Revision: D64500193
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D64870014

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Oct 29, 2024
…11337)

Summary:
Pull Request resolved: facebookincubator#11337

JODA has this concept of linked Time Zones where given a particular time zone ID, it
will write out a different time zone ID when formatting a timestamp as a string (I
suspect this is for historical reasons).

More information is available about this here https://github.com/JodaOrg/global-tz

This diff adds a script to parse the file JODA uses to get these links and turn it into a
static map. I've done this for the file in the version of JODA Presto Java currently uses
(there have been significant updates in more recent versions).  Note that the file
guarantees there are no transitive links so we don't need to handle that case.

I then updated the format_datetime UDF to use this mapping for the ZZZ (or more)
pattern.  It will use the linked time zone ID in place of the time zone ID if one is
available.

This is also fixes casting TimestampWithTimeZone to Varchar which uses the same
code path.

Reviewed By: xiaoxmeng

Differential Revision: D64870014
kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Oct 29, 2024
…11337)

Summary:
Pull Request resolved: facebookincubator#11337

JODA has this concept of linked Time Zones where given a particular time zone ID, it
will write out a different time zone ID when formatting a timestamp as a string (I
suspect this is for historical reasons).

More information is available about this here https://github.com/JodaOrg/global-tz

This diff adds a script to parse the file JODA uses to get these links and turn it into a
static map. I've done this for the file in the version of JODA Presto Java currently uses
(there have been significant updates in more recent versions).  Note that the file
guarantees there are no transitive links so we don't need to handle that case.

I then updated the format_datetime UDF to use this mapping for the ZZZ (or more)
pattern.  It will use the linked time zone ID in place of the time zone ID if one is
available.

This is also fixes casting TimestampWithTimeZone to Varchar which uses the same
code path.

Reviewed By: xiaoxmeng

Differential Revision: D64870014
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D64870014

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D64870014

kevinwilfong pushed a commit to kevinwilfong/velox that referenced this pull request Oct 29, 2024
…11337)

Summary:
Pull Request resolved: facebookincubator#11337

JODA has this concept of linked Time Zones where given a particular time zone ID, it
will write out a different time zone ID when formatting a timestamp as a string (I
suspect this is for historical reasons).

More information is available about this here https://github.com/JodaOrg/global-tz

This diff adds a script to parse the file JODA uses to get these links and turn it into a
static map. I've done this for the file in the version of JODA Presto Java currently uses
(there have been significant updates in more recent versions).  Note that the file
guarantees there are no transitive links so we don't need to handle that case.

I then updated the format_datetime UDF to use this mapping for the ZZZ (or more)
pattern.  It will use the linked time zone ID in place of the time zone ID if one is
available.

This is also fixes casting TimestampWithTimeZone to Varchar which uses the same
code path.

Reviewed By: xiaoxmeng

Differential Revision: D64870014
…11337)

Summary:
Pull Request resolved: facebookincubator#11337

JODA has this concept of linked Time Zones where given a particular time zone ID, it
will write out a different time zone ID when formatting a timestamp as a string (I
suspect this is for historical reasons).

More information is available about this here https://github.com/JodaOrg/global-tz

This diff adds a script to parse the file JODA uses to get these links and turn it into a
static map. I've done this for the file in the version of JODA Presto Java currently uses
(there have been significant updates in more recent versions).  Note that the file
guarantees there are no transitive links so we don't need to handle that case.

I then updated the format_datetime UDF to use this mapping for the ZZZ (or more)
pattern.  It will use the linked time zone ID in place of the time zone ID if one is
available.

This is also fixes casting TimestampWithTimeZone to Varchar which uses the same
code path.

Reviewed By: xiaoxmeng

Differential Revision: D64870014
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D64870014

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in b1834bd.

Copy link

Conbench analyzed the 1 benchmark run on commit b1834bde.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants