Skip to content

Commit 48b7ef4

Browse files
committed
more tests
1 parent 77f69a1 commit 48b7ef4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/IntervalUtilsSuite.scala

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import org.apache.spark.unsafe.types.CalendarInterval._
2424

2525
class IntervalUtilsSuite extends SparkFunSuite {
2626

27-
test("fromString") {
27+
test("fromString: basic") {
2828
testSingleUnit("YEAR", 3, 36, 0)
2929
testSingleUnit("Month", 3, 3, 0)
3030
testSingleUnit("Week", 3, 0, 3 * MICROS_PER_WEEK)
@@ -60,6 +60,23 @@ class IntervalUtilsSuite extends SparkFunSuite {
6060
}
6161
}
6262

63+
test("fromString: random order field") {
64+
val input = "1 day 1 year"
65+
val result = new CalendarInterval(12, MICROS_PER_DAY)
66+
assert(fromString(input) == result)
67+
}
68+
69+
test("fromString: duplicated fields") {
70+
val input = "1 day 1 day"
71+
val result = new CalendarInterval(0, 2 * MICROS_PER_DAY)
72+
assert(fromString(input) == result)
73+
}
74+
75+
test("fromString: value with +/-") {
76+
val input = "+1 year -1 day"
77+
val result = new CalendarInterval(12, -MICROS_PER_DAY)
78+
assert(fromString(input) == result)
79+
}
6380

6481
private def testSingleUnit(unit: String, number: Int, months: Int, microseconds: Long): Unit = {
6582
for (prefix <- Seq("interval ", "")) {

0 commit comments

Comments
 (0)