cloud-fan commented on a change in pull request #27672: [SPARK-30919][SQL] Make
interval multiply and divide's overflow behavior consistent with other
operations
URL: https://github.com/apache/spark/pull/27672#discussion_r383713490
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/IntervalExpressionsSuite.scala
##########
@@ -219,17 +224,23 @@ class IntervalExpressionsSuite extends SparkFunSuite
with ExpressionEvalHelper {
check("1 year 1 second", 0.5, "6 months 500 milliseconds")
check("-100 years -1 millisecond", 0.5, "-50 years -500 microseconds")
check("2 months 4 seconds", -0.5, "-1 months -2 seconds")
- check("1 month 2 microseconds", 1.5, "1 months 15 days 3 microseconds")
- check("2 months", Int.MaxValue, "integer overflow")
+ check("1 month 2 microseconds", 1.5, "1 months 3 microseconds")
+ check("2 months", Int.MaxValue, "integer overflow", Some(true))
+ check("2 months", Int.MaxValue, Int.MaxValue + " months", Some(false))
}
test("divide") {
- def check(interval: String, num: Double, expected: String): Unit = {
- val expr = DivideInterval(Literal(stringToInterval(interval)),
Literal(num))
+ def check(
+ interval: String,
+ num: Double,
+ expected: String,
+ isAnsi: Option[Boolean] = None): Unit = {
val expectedRes = safeStringToInterval(expected)
- Seq("true", "false").foreach { v =>
+ val configs = if (isAnsi.isEmpty) { Seq("true", "false") } else
isAnsi.map(_.toString).toSeq
Review comment:
super nit: `{ Seq("true", "false") }` -> `Seq("true", "false")`
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]