cloud-fan commented on a change in pull request #27537:
[SPARK-30668][SQL][FOLLOWUP] Raise exception instead of silent change for new
TimestampFormatter
URL: https://github.com/apache/spark/pull/27537#discussion_r382446239
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -787,6 +788,10 @@ abstract class ToTimestamp
formatter.parse(
Review comment:
can we create a util function to do it? e.g.
```
def parseTimestamp(formatter: TimestampFormatter, str: String, result:
LongWrapper): Boolean = {
try {
...
result.set(...)
true
} catch {
case e: DateTimeParseException =>
if (FAIL) throw ...
else false
case NonFatal(_) => false
}
}
```
and the caller side
```
val result = new LongWrapper
if (parseTimestamp(formatter, str, result)) {
result.get ... // whatever operations
} else {
null
}
```
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]