ARROW-13561: [C++] Implement week kernel that accepts WeekOptions#11026
ARROW-13561: [C++] Implement week kernel that accepts WeekOptions#11026rok wants to merge 11 commits intoapache:masterfrom
Conversation
|
Shall we also change |
f8d1e4c to
6997246
Compare
33b27e7 to
4a1b8a7
Compare
lidavidm
left a comment
There was a problem hiding this comment.
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.
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.
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.
Oh, no worries. I can hold off looking at this until you're ready.
There was a problem hiding this comment.
Early feedback is great though! :)
There was a problem hiding this comment.
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.
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.
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.
Added WeekOptions::ISODefaults and WeekOptions::USDefaults.
cpp/src/arrow/compute/api_scalar.h
Outdated
There was a problem hiding this comment.
It appears to be missing its counterpart in api_scalar.cc.
1d4a49c to
4f68c1c
Compare
|
Thanks for the review @lidavidm ! :) |
Co-authored-by: Ian Cook <[email protected]>
Co-authored-by: Ian Cook <[email protected]>
Co-authored-by: Joris Van den Bossche <[email protected]>
Co-authored-by: David Li <[email protected]>
|
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 <[email protected]> Co-authored-by: Rok Mihevc <[email protected]> Co-authored-by: Antoine Pitrou <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]>
This is to resolve ARROW-13561.