utkarsh39 commented on a change in pull request #30303:
URL: https://github.com/apache/spark/pull/30303#discussion_r520683563
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeUtilsSuite.scala
##########
@@ -518,18 +518,32 @@ class DateTimeUtilsSuite extends SparkFunSuite with
Matchers with SQLHelper {
assert(time == None)
}
- test("truncTimestamp") {
- def testTrunc(
- level: Int,
- expected: String,
- inputTS: Long,
- zoneId: ZoneId = defaultZoneId): Unit = {
- val truncated =
- DateTimeUtils.truncTimestamp(inputTS, level, zoneId)
- val expectedTS = toTimestamp(expected, defaultZoneId)
- assert(truncated === expectedTS.get)
+ def testTrunc(
+ level: Int,
+ expected: String,
+ inputTS: Long,
+ zoneId: ZoneId = defaultZoneId): Unit = {
+ val truncated = DateTimeUtils.truncTimestamp(inputTS, level, zoneId)
+ val expectedTS = toTimestamp(expected, defaultZoneId)
+ assert(truncated === expectedTS.get)
+ }
+
+ test("SPARK-33404: test truncTimestamp when time zone offset from UTC has a
" +
+ "granularity of seconds") {
+ for (zid <- ALL_TIMEZONES) {
+ withDefaultTimeZone(zid) {
+ val inputTS = DateTimeUtils.stringToTimestamp(
+ UTF8String.fromString("1769-10-17T17:10:02.123456"), defaultZoneId)
+ testTrunc(DateTimeUtils.TRUNC_TO_MINUTE, "1769-10-17T17:10:00",
inputTS.get, zid)
+ testTrunc(DateTimeUtils.TRUNC_TO_SECOND, "1769-10-17T17:10:02",
inputTS.get, zid)
+ testTrunc(DateTimeUtils.TRUNC_TO_MILLISECOND,
"1769-10-17T17:10:02.123", inputTS.get, zid)
+ testTrunc(DateTimeUtils.TRUNC_TO_MICROSECOND,
"1769-10-17T17:10:02.123456",
Review comment:
Yeah your guess is right.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]