dongjoon-hyun commented on code in PR #57110:
URL: https://github.com/apache/spark/pull/57110#discussion_r3541328482
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeUtilsSuite.scala:
##########
@@ -361,6 +361,24 @@ class DateTimeUtilsSuite extends SparkFunSuite with
Matchers with SQLHelper {
}
}
+ test("SPARK-58027: getZoneId normalizes legacy sign-prefixed offsets, passes
others through") {
+ // Sign-prefixed legacy formats are normalized: (+|-)h:mm -> (+|-)0h:mm,
(+|-)hh:m -> (+|-)hh:0m.
+ assert(getZoneId("+7:30") === ZoneId.of("+07:30"))
+ assert(getZoneId("-7:30") === ZoneId.of("-07:30"))
+ assert(getZoneId("+07:3") === ZoneId.of("+07:03"))
+ assert(getZoneId("-1:0") === ZoneId.of("-01:00"))
+ // Already-canonical sign offsets are unaffected by the normalization.
+ assert(getZoneId("+07:30") === ZoneId.of("+07:30"))
+ assert(getZoneId("-08:00") === ZoneId.of("-08:00"))
+ // Region-based IDs and other non-sign inputs bypass the regex
normalization unchanged. In
+ // particular "GMT+8" contains a '+' that is not the leading character, so
it must not be
+ // rewritten (matching the pre-guard behavior, where the sign-anchored
patterns never matched).
+ assert(getZoneId("UTC") === ZoneId.of("UTC"))
+ assert(getZoneId("Z") === ZoneId.of("Z"))
+ assert(getZoneId("America/New_York") === ZoneId.of("America/New_York"))
+ assert(getZoneId("GMT+8") === ZoneId.of("GMT+8", ZoneId.SHORT_IDS))
Review Comment:
Could you add a new test cases like `assert(getZoneId("GMT+8:00") ===
ZoneId.of("GMT+08:00"))`?
```suggestion
assert(getZoneId("GMT+8") === ZoneId.of("GMT+8", ZoneId.SHORT_IDS))
assert(getZoneId("GMT+8:00") === ZoneId.of("GMT+08:00"))
```
--
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]