rok commented on a change in pull request #11026:
URL: https://github.com/apache/arrow/pull/11026#discussion_r703612706
##########
File path: cpp/src/arrow/compute/api_scalar.h
##########
@@ -278,6 +278,23 @@ struct ARROW_EXPORT DayOfWeekOptions : public
FunctionOptions {
uint32_t week_start;
};
+struct ARROW_EXPORT WeekOptions : public FunctionOptions {
+ public:
+ explicit WeekOptions(bool week_starts_monday = true, bool count_from_zero =
false,
+ bool first_week_in_year = false);
+ constexpr static char const kTypeName[] = "WeekOptions";
+ static WeekOptions Defaults() { return WeekOptions{}; }
+
+ /// What day does the week start with (Monday=true, Sunday=false)
+ bool week_starts_monday;
+ /// Dates from current year that fall into last ISO week of the previous
year return
+ /// 0 if true and 52 or 53 if false.
+ bool count_from_zero;
Review comment:
From [MySQL
docs](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_week)
about why the 8 modes:
> If a date falls in the last week of the previous year, MySQL returns 0 if
you do not use 2, 3, 6, or 7 as the optional mode argument.
> One might argue that WEEK() should return 52 because the given date
actually occurs in the 52nd week of 1999. WEEK() returns 0 instead so that the
return value is “the week number in the given year.” This makes use of the
WEEK() function reliable when combined with other functions that extract a date
part from a date.
> If you prefer a result evaluated with respect to the year that contains
the first day of the week for the given date, use 0, 2, 5, or 7 as the optional
mode argument.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]