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 date_diff UDF with TimestampAndTimeZone and DST #11380

Closed

Conversation

kevinwilfong
Copy link
Contributor

Summary:
Presto Java's date_diff UDF respects DST for units greater than or equal to a day, but
for units less than a day computes the diff on the system time (GMT).

This means for units less than a day date_diff with TimestampWithTimeZone cannot
compute the difference of the local times. It needs to use system time to be
consistent.

Note that the for units greater than or equal to a day, this does not apply, and we
should continue to use the local time to compute the difference.

This is analogous to the change made to date_add in
#11353

Differential Revision: D65165953

@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 29, 2024
Copy link

netlify bot commented Oct 29, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit dad4d83
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/67226a2c06837e00083b9bd2

@facebook-github-bot
Copy link
Contributor

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

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

Summary:

Presto Java's date_diff UDF respects DST for units greater than or equal to a day, but
for units less than a day computes the diff on the system time (GMT).

This means for units less than a day date_diff with TimestampWithTimeZone cannot
compute the difference of the local times.  It needs to use system time to be
consistent.

Note that the for units greater than or equal to a day, this does not apply, and we
should continue to use the local time to compute the difference.

This is analogous to the change made to date_add in
facebookincubator#11353

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

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

Kevin Wilfong added 2 commits October 30, 2024 10:17
…incubator#11353)

Summary:

Presto Java's date_add UDF treats the day the clocks move forward as a 23 hour day,
and the day the clocks move back as a 25 hour day.

This means for units greater than or equal to a day date_add with
TimestampWithTimeZone cannot simply use the addition on GMT.  It needs to
compute the addition based on the local time to handle these.

Note that the for units less than a day, this does not apply, and will produce incorrect results if we compute it using local time.

Reviewed By: xiaoxmeng

Differential Revision: D64982873
…kincubator#11380)

Summary:

Presto Java's date_diff UDF respects DST for units greater than or equal to a day, but
for units less than a day computes the diff on the system time (GMT).

This means for units less than a day date_diff with TimestampWithTimeZone cannot
compute the difference of the local times.  It needs to use system time to be
consistent.

Note that the for units greater than or equal to a day, this does not apply, and we
should continue to use the local time to compute the difference.

This is analogous to the change made to date_add in
facebookincubator#11353

Reviewed By: xiaoxmeng

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

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

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 7377bc8.

Copy link

Conbench analyzed the 1 benchmark run on commit 7377bc80.

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