Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/7870#discussion_r36056759
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
---
@@ -494,44 +494,54 @@ object DateTimeUtils {
}
/**
- * Returns the month value for the given date. The date is expressed in
days
- * since 1.1.1970. January is month 1.
+ * Split date (expressed in days since 1.1.1970) into four fields:
+ * year, month (Jan is Month 1), dayInMonth, daysToMonthEnd (0 if it's
last day of month).
*/
- def getMonth(date: Int): Int = {
+ def splitDate(date: Int): (Int, Int, Int, Int) = {
var (year, dayInYear) = getYearAndDayInYear(date)
- if (isLeapYear(year)) {
- if (dayInYear == 60) {
- return 2
- } else if (dayInYear > 60) {
- dayInYear = dayInYear - 1
+ val isLeap = isLeapYear(year)
+ val (month, dayOfMonth, daysToMonthEnd) =
--- End diff --
yup tuples are bad, even if they are transient.
also - i might be wrong, but I think the destructive bind is actually
calling unapply under the hood, making it even more expensive.
---
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]