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_r387602824
########## File path: sql/core/src/test/scala/org/apache/spark/sql/CsvFunctionsSuite.scala ########## @@ -59,10 +59,23 @@ class CsvFunctionsSuite extends QueryTest with SharedSparkSession { val df2 = df .select(from_csv($"value", schemaWithCorrField1, Map( "mode" -> "Permissive", "columnNameOfCorruptRecord" -> columnNameOfCorruptRecord))) - - checkAnswer(df2, Seq( - Row(Row(0, null, "0,2013-111-11 12:13:14")), - Row(Row(1, java.sql.Date.valueOf("1983-08-04"), null)))) + withSQLConf(SQLConf.LEGACY_TIME_PARSER_POLICY.key -> "corrected") { + checkAnswer(df2, Seq( + Row(Row(0, null, "0,2013-111-11 12:13:14")), + Row(Row(1, java.sql.Date.valueOf("1983-08-04"), null)))) + } + withSQLConf(SQLConf.LEGACY_TIME_PARSER_POLICY.key -> "legacy") { + checkAnswer(df2, Seq( + Row(Row(0, java.sql.Date.valueOf("2022-03-11"), null)), + Row(Row(1, java.sql.Date.valueOf("1983-08-04"), null)))) + } + withSQLConf(SQLConf.LEGACY_TIME_PARSER_POLICY.key -> "exception") { + val msg = intercept[SparkException] { + df2.collect() + }.getCause.getMessage + assert(msg.contains(s"Set ${SQLConf.LEGACY_TIME_PARSER_POLICY.key} to LEGACY to restore " + Review comment: I think it's good enough to test if the `cause` is `SparkUpgradeException ` ---------------------------------------------------------------- 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