cloud-fan commented on a change in pull request #27537:
[SPARK-30668][SQL][FOLLOWUP] Raise exception instead of silent change for new
DateFormatter
URL: https://github.com/apache/spark/pull/27537#discussion_r387603645
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala
##########
@@ -2669,6 +2669,27 @@ abstract class JsonSuite extends QueryTest with
SharedSparkSession with TestJson
Date.valueOf("2020-1-12"),
Date.valueOf(LocalDate.ofEpochDay(12345))))
}
+
+ test("exception mode for parsing date/timestamp string") {
+ val ds = Seq("{'t': '2020-01-27T20:06:11.847-0800'}").toDS()
+ val json = spark.read
+ .schema("t timestamp")
+ .option("timestampFormat", "yyyy-MM-dd'T'HH:mm:ss.SSSz")
+ .json(ds)
+ withSQLConf(SQLConf.LEGACY_TIME_PARSER_POLICY.key -> "exception") {
+ val msg = intercept[SparkException] {
+ json.collect()
+ }.getCause.getMessage
+ assert(msg.contains(s"Set ${SQLConf.LEGACY_TIME_PARSER_POLICY.key} to
LEGACY to restore " +
Review comment:
ditto
----------------------------------------------------------------
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]