gatorsmile commented on a change in pull request #27441: [SPARK-30668][SQL]
Support `SimpleDateFormat` patterns in parsing timestamps/dates strings
URL: https://github.com/apache/spark/pull/27441#discussion_r376021523
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/DateFunctionsSuite.scala
##########
@@ -789,4 +789,18 @@ class DateFunctionsSuite extends QueryTest with
SharedSparkSession {
Row(Timestamp.valueOf("2015-07-24 07:00:00")),
Row(Timestamp.valueOf("2015-07-24 22:00:00"))))
}
+
+ test("SPARK-30668: use legacy timestamp parser in to_timestamp") {
+ def checkTimeZoneParsing(expected: Any): Unit = {
+ val df = Seq("2020-01-27T20:06:11.847-0800").toDF("ts")
+ checkAnswer(df.select(to_timestamp(col("ts"),
"yyyy-MM-dd'T'HH:mm:ss.SSSz")),
+ Row(expected))
+ }
+ withSQLConf(SQLConf.LEGACY_TIME_PARSER_ENABLED.key -> "true") {
+ checkTimeZoneParsing(Timestamp.valueOf("2020-01-27 20:06:11.847"))
+ }
+ withSQLConf(SQLConf.LEGACY_TIME_PARSER_ENABLED.key -> "false") {
+ checkTimeZoneParsing(null)
Review comment:
fallback to the old parser?
----------------------------------------------------------------
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]