dongjoon-hyun commented on a change in pull request #26261: [SPARK-29607][SQL] 
Move static methods from CalendarInterval to IntervalUtils
URL: https://github.com/apache/spark/pull/26261#discussion_r339277764
 
 

 ##########
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/IntervalUtilsSuite.scala
 ##########
 @@ -87,4 +87,57 @@ class IntervalUtilsSuite extends SparkFunSuite {
       assert(fromString(input2) == result)
     }
   }
+
+  test("from year-month string") {
+    assert(fromYearMonthString("99-10") === new CalendarInterval(99 * 12 + 10, 
0L))
+    assert(fromYearMonthString("-8-10") === new CalendarInterval(-8 * 12 - 10, 
0L))
+
+    try {
+      fromYearMonthString("99-15")
+      fail("Expected to throw an exception for the invalid input")
+    } catch {
+      case e: IllegalArgumentException =>
+        assert(e.getMessage.contains("month 15 outside range"))
+    }
+  }
+
+  test("from day-time string") {
+    assert(fromDayTimeString("5 12:40:30.999999999") ===
+      new CalendarInterval(
+        0,
+        5 * MICROS_PER_DAY +
+          12 * MICROS_PER_HOUR +
+          40 * MICROS_PER_MINUTE +
+          30 * MICROS_PER_SECOND + 999999L))
+    assert(fromDayTimeString("10 0:12:0.888") ===
+      new CalendarInterval(
+        0,
+        10 * MICROS_PER_DAY + 12 * MICROS_PER_MINUTE + 888 * MICROS_PER_MILLI))
+    assert(fromDayTimeString("-3 0:0:0") ===
+      new CalendarInterval(0, -3 * MICROS_PER_DAY))
 
 Review comment:
   ```scala
   assert(fromDayTimeString("-3 0:0:0") === new CalendarInterval(0, -3 * 
MICROS_PER_DAY))
   ```

----------------------------------------------------------------
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]

Reply via email to