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 Presto's format_datetime function with time zone #11283

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kevinwilfong
Copy link
Contributor

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

Kevin Wilfong added 2 commits October 16, 2024 15:06
Summary:

Presto's to_iso8601 UDF uses JODA's default ISODateTimeFormat.dateTime()
formatter which uses the string 'Z' in place of the time zone offset if the time zone is
UTC.
https://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--

Internally JODA's DateTimeFormatter does this by taking an optional hard coded
string to use for the time zone offset if it's zero. I added something similar to Velox's
DateTimeFormatter.format and setting it in the to_iso8601 implementation.

I checked and other Presto UDFs that format TimestampWithTimeZones as strings,
e.g. format_datetime, do not use this option, so they do not need to be updated.

Differential Revision: D64488962
Summary:
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 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 16, 2024
@facebook-github-bot
Copy link
Contributor

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

Copy link

netlify bot commented Oct 16, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 6a0e062
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/671038ea5ea9ca00093c9100

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants