Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add the test "converting java.time.Duration to CalendarIntervalType"
  • Loading branch information
MaxGekk committed Oct 11, 2019
commit 6f231e5a64143da922ccbd4378bb0fbe14cac749
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.spark.sql.catalyst

import java.time.{Instant, LocalDate}
import java.time.{Duration, Instant, LocalDate}

import org.apache.spark.SparkFunSuite
import org.apache.spark.sql.Row
Expand Down Expand Up @@ -216,4 +216,18 @@ class CatalystTypeConvertersSuite extends SparkFunSuite with SQLHelper {
}
}
}

test("converting java.time.Duration to CalendarIntervalType") {
Seq(
"P0D",
"PT0.000001S",
"PT-0.000001S",
"P1DT2H3M4.000001S",
"P-1DT2H3M4.000001S").foreach { time =>
val input = Duration.parse(time)
val result = CatalystTypeConverters.convertToCatalyst(input)
val expected = DateTimeUtils.durationToInterval(input)
assert(result === expected)
}
}
}