-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
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
✅ Deploy Preview for meta-velox canceled.
|
This pull request was exported from Phabricator. Differential Revision: D60427017 |
There was a problem hiding this 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
This pull request has been merged in f8f538e. |
Conbench analyzed the 1 benchmark run on commit There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
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
Summary: Similar to facebookincubator#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: facebookincubator#10713 Reviewed By: DanielHunte Differential Revision: D63269551 Pulled By: pedroerp fbshipit-source-id: cf8cf8b4f2a917d7a7c16a03cc8feed5f3fed5d8
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