dgd-contributor commented on a change in pull request #33293:
URL: https://github.com/apache/spark/pull/33293#discussion_r667814463
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
##########
@@ -237,114 +237,114 @@ object DateTimeUtils {
* - Region-based zone IDs in the form `area/city`, such as `Europe/Paris`
*/
def stringToTimestamp(s: UTF8String, timeZoneId: ZoneId): Option[Long] = {
- if (s == null) {
- return None
- }
- var tz: Option[String] = None
- val segments: Array[Int] = Array[Int](1, 1, 1, 0, 0, 0, 0, 0, 0)
- var i = 0
- var currentSegmentValue = 0
- val bytes = s.trimAll().getBytes
- val specialTimestamp = convertSpecialTimestamp(bytes, timeZoneId)
- if (specialTimestamp.isDefined) return specialTimestamp
- var j = 0
- var digitsMilli = 0
- var justTime = false
- while (j < bytes.length) {
- val b = bytes(j)
- val parsedValue = b - '0'.toByte
- if (parsedValue < 0 || parsedValue > 9) {
- if (j == 0 && b == 'T') {
- justTime = true
- i += 3
- } else if (i < 2) {
- if (b == '-') {
- if (i == 0 && j != 4) {
- // year should have exact four digits
+ try {
Review comment:
As in master branch, I see that the whole block is wrapped in, and I
think we should make the whole block with try catch for better understandable
and avoid corruption
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
##########
@@ -237,114 +237,114 @@ object DateTimeUtils {
* - Region-based zone IDs in the form `area/city`, such as `Europe/Paris`
*/
def stringToTimestamp(s: UTF8String, timeZoneId: ZoneId): Option[Long] = {
- if (s == null) {
- return None
- }
- var tz: Option[String] = None
- val segments: Array[Int] = Array[Int](1, 1, 1, 0, 0, 0, 0, 0, 0)
- var i = 0
- var currentSegmentValue = 0
- val bytes = s.trimAll().getBytes
- val specialTimestamp = convertSpecialTimestamp(bytes, timeZoneId)
- if (specialTimestamp.isDefined) return specialTimestamp
- var j = 0
- var digitsMilli = 0
- var justTime = false
- while (j < bytes.length) {
- val b = bytes(j)
- val parsedValue = b - '0'.toByte
- if (parsedValue < 0 || parsedValue > 9) {
- if (j == 0 && b == 'T') {
- justTime = true
- i += 3
- } else if (i < 2) {
- if (b == '-') {
- if (i == 0 && j != 4) {
- // year should have exact four digits
+ try {
Review comment:
yes, the factored function is wrapped with try-catch, and the factored
function included the whole block and try catch is wrapped whole function
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]