MaxGekk commented on a change in pull request #28576:
URL: https://github.com/apache/spark/pull/28576#discussion_r427137030
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/util/TimestampFormatterSuite.scala
##########
@@ -291,4 +291,95 @@ class TimestampFormatterSuite extends SparkFunSuite with
SQLHelper with Matchers
}
}
}
+
+ test("parsing hour with various patterns") {
+ def createFormatter(pattern: String): TimestampFormatter = {
+ // Use `SIMPLE_DATE_FORMAT`, so that the legacy parser also fails with
invalid value range.
+ TimestampFormatter(pattern, ZoneOffset.UTC,
LegacyDateFormats.SIMPLE_DATE_FORMAT, false)
+ }
+
+ withClue("HH") {
+ val formatter = createFormatter("yyyy-MM-dd HH")
+
+ val micros1 = formatter.parse("2009-12-12 00")
+ assert(micros1 === TimeUnit.SECONDS.toMicros(
+ LocalDateTime.of(2009, 12, 12, 0, 0, 0).toEpochSecond(ZoneOffset.UTC)))
Review comment:
Can you use DateTimeTestUtils.days
https://github.com/apache/spark/blob/9f0c010a5c9b5c10401f8e16fa7a151714b6dbb0/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeTestUtils.scala#L72-L85?
----------------------------------------------------------------
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]