Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/6986#discussion_r35582133
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
---
@@ -573,4 +573,48 @@ object DateTimeUtils {
dayInYear - 334
}
}
+
+ /**
+ * Returns Day of week from String. Starting from friday, marked as 0.
+ */
+ def getDayOfWeekFromString(string: UTF8String): Int = {
+ val dowString = string.toString.toUpperCase
+ dowString match {
+ case "SU" | "SUN" | "SUNDAY" => 2
+ case "MO" | "MON" | "MONDAY" => 3
+ case "TU" | "TUE" | "TUESDAY" => 4
+ case "WE" | "WED" | "WEDNESDAY" => 5
+ case "TH" | "THU" | "THURSDAY" => 6
+ case "FR" | "FRI" | "FRIDAY" => 0
+ case "SA" | "SAT" | "SATURDAY" => 1
+ case _ => -1
+ }
+ }
+
+ /**
+ * Returns the first date which is later than startDate and is of the
given dayOfWeek.
+ */
+ def getNextDateForDayOfWeek(startDate: Int, dayOfWeek: Int): Int = {
--- End diff --
we should document what dayOfWeek here means, i.e. in this case, Fri is 0,
Sat is 1 ...
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]