-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-13561: [C++] Implement week kernel that accepts WeekOptions #11026
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
Conversation
|
Shall we also change |
f8d1e4c to
6997246
Compare
33b27e7 to
4a1b8a7
Compare
lidavidm
left a comment
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.
So essentially, ISOWeek starts from 1, Week starts from 0, and neither use DayOfWeekOptions.week_start? In that case I would just make them two optionless kernels.
To get parity with MySQL |
Ah, ok. But unless I'm mistaken, week_start is not actually used by the week kernel. |
I'm just trying to understand if it does :) |
|
This evaluates to true in MySQL on sqlfiddle: SELECT WEEK('2008-1-6', 1) != WEEK('2008-1-6', 4)
|
18a2b49 to
69eed89
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.
Given ISOWeek is a special case of Week now, maybe we should just have one kernel (and perhaps some conveniences, e.g. DayOfWeekOptions::IsoWeek())?
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.
Oh yeah, that's a nice idea.
I'm still trying to exactly match WEEK from MySQL and once I do I'll look into this. Sorry for the WIP.
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.
Oh, no worries. I can hold off looking at this until you're ready.
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.
Early feedback is great though! :)
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.
Ping on this? Since it seems the two kernels are very similar.
|
@ianmcook This now covers MySQL WEEK modes 1, 3, 4 and 6 (week 1 is the first week with 4 or more days this year). Another thing to note here is that |
Perhaps |
|
If the option doesn't apply to DayOfWeek, maybe it should be a separate WeekOptions in that case. |
|
So then we now have: We would need to add three binary parameters to match the 8 modes of MySQL:
|
|
I tried adding I've also added tests with all the MySQL modes. Docs and the logic need some more work, but first: do we go this way or stick to iso week only? |
ef87424 to
062e5f2
Compare
I suppose we then need ISOWeek and USWeek declared with options in the API. |
|
Yeah, we'd need a case here: Line 129 in 075c6c6
|
lidavidm
left a comment
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.
Some nits on style/wording.
If you're up to add R tests, I think that would be appreciated, but otherwise we can put that in a follow-up JIRA (since there might be other work to bind the new kernels to dplyr features or whatnot).
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.
Similarly here, can we put comments for the parameter literals? Or actually, it might be nice to define WeekOptions::IsoDefaults and WeekOptions::UsDefaults which could then be used here and in the R bindings.
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.
Added WeekOptions::ISODefaults and WeekOptions::USDefaults.
cpp/src/arrow/compute/api_scalar.h
Outdated
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.
Also add a helper for USWeek?
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.
Done.
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.
It appears to be missing its counterpart in api_scalar.cc.
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.
Added.
1d4a49c to
4f68c1c
Compare
lidavidm
left a comment
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, LGTM.
|
Thanks for the review @lidavidm ! :) |
Co-authored-by: Ian Cook <ianmcook@gmail.com>
Co-authored-by: Ian Cook <ianmcook@gmail.com>
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Co-authored-by: David Li <li.davidm96@gmail.com>
pitrou
left a comment
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.
Rebased, will merge
|
Thanks @pitrou @ianmcook @jorisvandenbossche @lidavidm ! |
This is to resolve [ARROW-13561](https://issues.apache.org/jira/browse/ARROW-13561`). Closes apache#11026 from rok/ARROW-13561 Lead-authored-by: Rok <rok@mihevc.org> Co-authored-by: Rok Mihevc <rok@mihevc.org> Co-authored-by: Antoine Pitrou <antoine@python.org> Signed-off-by: Antoine Pitrou <antoine@python.org>
This is to resolve ARROW-13561.