cloud-fan commented on a change in pull request #30442:
URL: https://github.com/apache/spark/pull/30442#discussion_r528565942
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/DateExpressionsSuite.scala
##########
@@ -1286,4 +1287,47 @@ class DateExpressionsSuite extends SparkFunSuite with
ExpressionEvalHelper {
testIntegralFunc(Long.MaxValue)
testIntegralFunc(Long.MinValue)
}
+
+ test("SPARK-33498: GetTimestamp,UnixTimestamp,ToUnixTimestamp with
parseError") {
+ Seq(true, false).foreach { ansiEnabled =>
+ Seq("LEGACY", "CORRECTED", "EXCEPTION").foreach { policy =>
+ withSQLConf(SQLConf.LEGACY_TIME_PARSER_POLICY.key -> policy,
+ SQLConf.ANSI_ENABLED.key -> ansiEnabled.toString) {
+
+ val exprSeq = Seq[Expression](
+ GetTimestamp(Literal("2020-01-27T20:06:11.847"),
Literal("yyyy-MM-dd HH:mm:ss.SSS")),
+ GetTimestamp(Literal("Unparseable"), Literal("yyyy-MM-dd
HH:mm:ss.SSS")),
+ UnixTimestamp(Literal("2020-01-27T20:06:11.847"),
Literal("yyyy-MM-dd HH:mm:ss.SSS")),
+ UnixTimestamp(Literal("Unparseable"), Literal("yyyy-MM-dd
HH:mm:ss.SSS")),
+ ToUnixTimestamp(Literal("2020-01-27T20:06:11.847"),
Literal("yyyy-MM-dd HH:mm:ss.SSS")),
+ ToUnixTimestamp(Literal("Unparseable"), Literal("yyyy-MM-dd
HH:mm:ss.SSS"))
+ )
+
+ if (!ansiEnabled) {
+ exprSeq.foreach(checkEvaluation(_, null))
+ } else if (policy == "LEGACY") {
+ exprSeq.foreach(checkExceptionInExpression[ParseException](_,
"Unparseable"))
+ } else {
+ exprSeq.foreach(
+ checkExceptionInExpression[DateTimeParseException](_, "could not
be parsed"))
+ }
+ }
+ }
+ }
+ }
+
+ test("SPARK-33498: TimestampType cast with parseError") {
Review comment:
is it duplicated with `CastSuiteBase`?
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]