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

WeekFunction calculates long years incorrectly #10599

Closed

Conversation

kevinwilfong
Copy link
Contributor

Summary:
The WeekFunction treats leap years that end on Saturday, and any year that ends on Friday or
Thursday as a year with 53 weeks.

However, according to Wikipedia https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year years
with 53 weeks are leap years that end on Friday and any year that ends on Thursday.

I updated the logic to reflect this.

I added tests to cover cases where we end up in Week 0, which is the only case where this logic is
used, and verified the results match Presto Java.

Differential Revision: D60427017

Summary:
The WeekFunction treats leap years that end on Saturday, and any year that ends on Friday or
Thursday as a year with 53 weeks.

However, according to Wikipedia https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year years
with 53 weeks are leap years that end on Friday and any year that ends on Thursday.

I updated the logic to reflect this.

I added tests to cover cases where we end up in Week 0, which is the only case where this logic is
used, and verified the results match Presto Java.

Differential Revision: D60427017
@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 Jul 30, 2024
Copy link

netlify bot commented Jul 30, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 0c56ef2
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/66a83420e00eca0008fc3961

@facebook-github-bot
Copy link
Contributor

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

Copy link
Contributor

@amitkdutta amitkdutta left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks @kevinwilfong

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in f8f538e.

Copy link

Conbench analyzed the 1 benchmark run on commit f8f538ec.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

facebook-github-bot pushed a commit that referenced this pull request Oct 1, 2024
Summary:
Similar to #10599, in Spark, a long year is any year ending on Thursday and any
leap year ending on Friday. Since the only difference between Presto and Spark
is on return type, this PR extracts the 'getWeek' function to functions/lib and
changed to use 'weeknum' from external/date library for the week calculation.

Pull Request resolved: #10713

Reviewed By: DanielHunte

Differential Revision: D63269551

Pulled By: pedroerp

fbshipit-source-id: cf8cf8b4f2a917d7a7c16a03cc8feed5f3fed5d8
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