-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[SPARK-9549][SQL] fix bugs in expressions #7882
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -614,8 +614,9 @@ object DateTimeUtils { | |
*/ | ||
def dateAddMonths(days: Int, months: Int): Int = { | ||
val absoluteMonth = (getYear(days) - YearZero) * 12 + getMonth(days) - 1 + months | ||
val currentMonthInYear = absoluteMonth % 12 | ||
val currentYear = absoluteMonth / 12 | ||
val nonNegativeMonth = if (absoluteMonth >= 0) absoluteMonth else 0 | ||
val currentMonthInYear = nonNegativeMonth % 12 | ||
val currentYear = nonNegativeMonth / 12 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The above two statements can be replaced with: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is that possible? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /% is not defined for Int. I read the notion in a Scala book which I have returned. I will read more once I have that book back. |
||
val leapDay = if (currentMonthInYear == 1 && isLeapYear(currentYear + YearZero)) 1 else 0 | ||
val lastDayOfMonth = monthDays(currentMonthInYear) + leapDay | ||
|
||
|
@@ -626,7 +627,7 @@ object DateTimeUtils { | |
} else { | ||
dayOfMonth | ||
} | ||
firstDayOfMonth(absoluteMonth) + currentDayInMonth - 1 | ||
firstDayOfMonth(nonNegativeMonth) + currentDayInMonth - 1 | ||
} | ||
|
||
/** | ||
|
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.
our codegen can handle boolean type, doesn't it?
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.
see https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala#L231
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.
yes, but without test against
BooleanType
, it would userather than the else part, therefore,
genComp
is not used.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.
ah ic, makes sense, good catch!