-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add week_of_year Spark function #5941
Conversation
✅ Deploy Preview for meta-velox canceled.
|
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.
Can we put Spark's implementation to the PR description?
6b55ab9
to
a5029ab
Compare
I0807 10:11:07.190543 1754778 ExpressionFuzzer.cpp:1313] ==============================> Started iteration 74530 (seed: 1635755765) |
a5029ab
to
36f73ab
Compare
@mbasmanova Could you help to review this pr? |
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.
@Ma-Jian1 Would you review contributing guide and update accordingly. Specifically, make sure the PR title and description are in compliance.
36f73ab
to
4874526
Compare
Sorry for that. |
@@ -52,6 +52,13 @@ These functions support TIMESTAMP and DATE input types. | |||
Returns null if ``string`` does not match ``format`` or if ``format`` | |||
is invalid. | |||
|
|||
.. function:: week(x) -> integer |
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.
The PR title says "week_of_year", but this doc says "week". Which is correct?
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.
fixed to week_of_year
.. function:: week(x) -> integer | ||
|
||
Returns the `ISO-Week`_ of the year from x. The value ranges from ``1`` to ``53``. | ||
A week is considered to start on a Monday and week 1 is the first week with >3 days. |
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.
Would you double check that this matches Spark's implementation?
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.
Add some extra ut that copy from Spark UT, and validate the results.
From https://github.com/apache/spark/blob/v3.2.2/sql/core/src/main/scala/org/apache/spark/sql/functions.scala#L3240-L3241, It also follows ISO 8601
4874526
to
d8318ab
Compare
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.
Thanks. There are some tooling issues blocking me from merging this PR. These should be resolved sometime tomorrow.
@mbasmanova Can this PR be merged? |
@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Let me try. Would you rebase? |
@mbasmanova merged this pull request in 15e1782. |
Conbench analyzed the 1 benchmark run on commit There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
Summary: Presto's `week_of_year` function differs from Spark's in return type: BIGINT vs. INTEGER. Copy-paste Presto's implementation and change the return type. Spark's implementation: https://github.com/apache/spark/blob/v3.2.2/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala#L868 Pull Request resolved: facebookincubator#5941 Reviewed By: amitkdutta Differential Revision: D48224232 Pulled By: mbasmanova fbshipit-source-id: 19313b0294a8aa714b017deb4623ba1422084a35
Summary: Presto's `week_of_year` function differs from Spark's in return type: BIGINT vs. INTEGER. Copy-paste Presto's implementation and change the return type. Spark's implementation: https://github.com/apache/spark/blob/v3.2.2/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala#L868 Pull Request resolved: facebookincubator#5941 Reviewed By: amitkdutta Differential Revision: D48224232 Pulled By: mbasmanova fbshipit-source-id: 19313b0294a8aa714b017deb4623ba1422084a35
Presto's
week_of_year
function differs from Spark's in return type: BIGINT vs. INTEGER.Copy-paste Presto's implementation and change the return type.
Spark's implementation: https://github.com/apache/spark/blob/v3.2.2/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala#L868