You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/02/21 08:12:32 UTC
[GitHub] [spark] cloud-fan commented on a change in pull request #27537:
[SPARK-30668][SQL][FOLLOWUP] Raise exception instead of silent change for
new TimestampFormatter
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:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org