MaxGekk commented on a change in pull request #27753: [SPARK-31005][SQL]
Support time zone ids in casting strings to timestamps
URL: https://github.com/apache/spark/pull/27753#discussion_r387682760
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeUtilsSuite.scala
##########
@@ -213,38 +217,30 @@ class DateTimeUtilsSuite extends SparkFunSuite with
Matchers with SQLHelper {
expected = Option(date(2015, 3, 18, 12, 3, 17, 456000, zid = zoneId))
checkStringToTimestamp("2015-03-18T12:03:17.456Z", expected)
checkStringToTimestamp("2015-03-18 12:03:17.456Z", expected)
+ checkStringToTimestamp("2015-03-18 12:03:17.456UTC", expected)
zoneId = getZoneId("GMT-01:00")
expected = Option(date(2015, 3, 18, 12, 3, 17, 123000, zid = zoneId))
checkStringToTimestamp("2015-03-18T12:03:17.123-1:0", expected)
checkStringToTimestamp("2015-03-18T12:03:17.123-01:00", expected)
+ checkStringToTimestamp("2015-03-18T12:03:17.123GMT-01:00", expected)
zoneId = getZoneId("GMT+07:30")
expected = Option(date(2015, 3, 18, 12, 3, 17, 123000, zid = zoneId))
checkStringToTimestamp("2015-03-18T12:03:17.123+07:30", expected)
+ checkStringToTimestamp("2015-03-18T12:03:17.123GMT+07:30", expected)
Review comment:
This format is not supported by ZoneId. I put all supported formats to the
PR's description:
```scala
scala> getZoneId("GMT+7:30")
java.time.DateTimeException: Invalid ID for offset-based ZoneId: GMT+7:30
at java.time.ZoneId.ofWithPrefix(ZoneId.java:437)
at java.time.ZoneId.of(ZoneId.java:407)
at java.time.ZoneId.of(ZoneId.java:359)
at java.time.ZoneId.of(ZoneId.java:315)
at
org.apache.spark.sql.catalyst.util.DateTimeUtils$.getZoneId(DateTimeUtils.scala:57)
... 53 elided
Caused by: java.time.DateTimeException: Invalid ID for ZoneOffset, non
numeric characters found: +7:30
at java.time.ZoneOffset.parseNumber(ZoneOffset.java:269)
at java.time.ZoneOffset.of(ZoneOffset.java:221)
at java.time.ZoneId.ofWithPrefix(ZoneId.java:431)
... 57 more
scala> getZoneId("GMT+7")
res5: java.time.ZoneId = GMT+07:00
scala> getZoneId("GMT+07:30")
res6: java.time.ZoneId = GMT+07:30
```
----------------------------------------------------------------
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]