You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "srowen (via GitHub)" <gi...@apache.org> on 2023/05/07 15:11:26 UTC
[GitHub] [spark] srowen commented on a diff in pull request #41078: [SPARK-39280][SQL] Speed up Timestamp type inference with user-provided format in JSON/CSV data source
srowen commented on code in PR #41078:
URL: https://github.com/apache/spark/pull/41078#discussion_r1186870024
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/TimestampFormatter.scala:
##########
@@ -163,27 +165,66 @@ class Iso8601TimestampFormatter(
protected lazy val legacyFormatter = TimestampFormatter.getLegacyFormatter(
pattern, zoneId, locale, legacyFormat)
+ override def parseOptional(s: String): Option[Long] = {
+ try {
+ val parsed = formatter.parseUnresolved(s, new ParsePosition(0))
+ if (parsed != null) {
+ val (epochSeconds, microsOfSecond) = extractSeconds(parsed)
+ Some(Math.addExact(Math.multiplyExact(epochSeconds, MICROS_PER_SECOND), microsOfSecond))
+ } else {
+ None
+ }
+ } catch {
+ case NonFatal(_) => None
Review Comment:
You're saying you're avoiding exceptions, but then this catches exceptions. Is this just the fall-back case for unexpected errors?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org