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_r387603300
########## File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala ########## @@ -2307,6 +2307,27 @@ abstract class CSVSuite extends QueryTest with SharedSparkSession with TestCsvDa val csv = spark.read.option("header", false).schema("t timestamp, d date").csv(ds) checkAnswer(csv, Row(Timestamp.valueOf("2020-1-12 3:23:34.12"), Date.valueOf("2020-1-12"))) } + + test("exception mode for parsing date/timestamp string") { + val ds = Seq("2020-01-27T20:06:11.847-0800").toDS() + val csv = spark.read + .option("header", false) + .option("timestampFormat", "yyyy-MM-dd'T'HH:mm:ss.SSSz") + .schema("t timestamp").csv(ds) + withSQLConf(SQLConf.LEGACY_TIME_PARSER_POLICY.key -> "exception") { + val msg = intercept[SparkException] { + csv.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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org