cloud-fan commented on a change in pull request #30442:
URL: https://github.com/apache/spark/pull/30442#discussion_r530367089
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala
##########
@@ -945,6 +934,36 @@ abstract class AnsiCastSuiteBase extends CastSuiteBase {
cast("abcd", DecimalType(38, 1)),
"invalid input syntax for type numeric")
}
+
+ test("ANSI mode: cast string to timestamp with parse error") {
+ val currentAnsiEnabled = SQLConf.get.ansiEnabled
+ new ParVector(ALL_TIMEZONES.toVector).foreach { zid =>
+ def checkCastWithParseError(str: String): Unit = {
+ checkExceptionInExpression[DateTimeException](
+ cast(Literal(str), TimestampType, Option(zid.getId)),
+ s"Cannot cast $str to TimestampType.")
+ }
+
+ withSQLConf(SQLConf.ANSI_ENABLED.key -> currentAnsiEnabled.toString) {
Review comment:
to be more robust:
```
val activeConf = conf
new ParVector...
SQLConf.withExistingConf(activeConf) ...
```
----------------------------------------------------------------
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]