beliefer commented on code in PR #44110: URL: https://github.com/apache/spark/pull/44110#discussion_r1413737755
########## sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/SparkDateTimeUtils.scala: ########## @@ -305,21 +305,32 @@ trait SparkDateTimeUtils { (segment == 0 && digits >= 4 && digits <= maxDigitsYear) || (segment != 0 && digits > 0 && digits <= 2) } - if (s == null || s.trimAll().numBytes() == 0) { + if (s == null) { return None } + val segments: Array[Int] = Array[Int](1, 1, 1) var sign = 1 var i = 0 var currentSegmentValue = 0 var currentSegmentDigits = 0 - val bytes = s.trimAll().getBytes Review Comment: We can reuse the `trimLeft` here. ########## sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/SparkDateTimeUtils.scala: ########## @@ -305,21 +305,32 @@ trait SparkDateTimeUtils { (segment == 0 && digits >= 4 && digits <= maxDigitsYear) || (segment != 0 && digits > 0 && digits <= 2) } - if (s == null || s.trimAll().numBytes() == 0) { + if (s == null) { return None } + val segments: Array[Int] = Array[Int](1, 1, 1) var sign = 1 var i = 0 var currentSegmentValue = 0 var currentSegmentDigits = 0 - val bytes = s.trimAll().getBytes + val bytes = s.getBytes var j = 0 + + while (j < bytes.length && UTF8String.isWhitespaceOrISOControl(bytes(j))) { + j += 1; + } Review Comment: After using `trimLeft`, we can delete the three lines. -- 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