cloud-fan commented on code in PR #44110: URL: https://github.com/apache/spark/pull/44110#discussion_r1413748213
########## 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; + } + + if (j == bytes.length) { + return None; + } + if (bytes(j) == '-' || bytes(j) == '+') { sign = if (bytes(j) == '-') -1 else 1 j += 1 } - while (j < bytes.length && (i < 3 && !(bytes(j) == ' ' || bytes(j) == 'T'))) { + while (j < bytes.length && + (i < 3 && !(UTF8String.isWhitespaceOrISOControl(bytes(j)) || bytes(j) == 'T'))) { Review Comment: oh is this a behavior change? now not only spaces, but also ISO controls are allowed in the middle. -- 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