gatorsmile commented on a change in pull request #28736:
URL: https://github.com/apache/spark/pull/28736#discussion_r449184881
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeFormatterHelper.scala
##########
@@ -126,6 +130,25 @@ trait DateTimeFormatterHelper {
s"before Spark 3.0, or set to CORRECTED and treat it as an invalid
datetime string.", e)
}
+ // When legacy time parser policy set to EXCEPTION, check whether we will
get different results
+ // between legacy formatter and new formatter. If new formatter fails but
legacy formatter works,
+ // throw a SparkUpgradeException. On the contrary, if the legacy policy set
to CORRECTED,
+ // DateTimeParseException will address by the caller side.
+ protected def checkFormattedDiff[T <: Date](
+ d: T,
+ legacyFormatFunc: T => String): PartialFunction[Throwable, String] = {
+ case e if needConvertToSparkUpgradeException(e) =>
+ val resultCandidate = try {
+ legacyFormatFunc(d)
+ } catch {
+ case _: Throwable => throw e
+ }
+ throw new SparkUpgradeException("3.0", s"Fail to format it to
'$resultCandidate' in the new" +
Review comment:
@HyukjinKwon Should we combine the JVM stacktrace for
SparkUpgradeException in the python side?
----------------------------------------------------------------
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]