gengliangwang commented on code in PR #36562: URL: https://github.com/apache/spark/pull/36562#discussion_r874864869
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/TimestampFormatter.scala: ########## @@ -52,6 +52,25 @@ sealed trait TimestampFormatter extends Serializable { @throws(classOf[DateTimeException]) def parse(s: String): Long + /** + * Parses a timestamp in a string and converts it to an optional number of microseconds. + * + * @param s - string with timestamp to parse + * @return An optional number of microseconds since epoch. The result is None on invalid input. + * @throws ParseException can be thrown by legacy parser + * @throws DateTimeParseException can be thrown by new parser + * @throws DateTimeException unable to obtain local date or time + */ + @throws(classOf[ParseException]) + @throws(classOf[DateTimeParseException]) + @throws(classOf[DateTimeException]) + def parseOptional(s: String): Option[Long] = + try { + Some(parse(s)) + } catch { Review Comment: For the default timestamp formatter, there is an override version which is certainly faster: https://github.com/apache/spark/pull/36562/files#diff-b42bcba727feeebf78f0e5540f2d4f6c6a38afd2225e4ebeae22a604e42eb094R251 If user set a customized timestamp format, or set the SQL conf to use legacy timestamp format, the performance is not changed. -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org