You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "LuciferYang (via GitHub)" <gi...@apache.org> on 2026/07/08 03:50:00 UTC

[PR] [SPARK-58027][SQL] Avoid unnecessary Matcher allocation in getZoneId for region-based zone IDs [spark]

LuciferYang opened a new pull request, #57110:
URL: https://github.com/apache/spark/pull/57110

   ### What changes were proposed in this pull request?
   
   `SparkDateTimeUtils.getZoneId` runs two regex `replaceFirst` calls on every invocation to normalize the legacy `(+|-)h:mm` and `(+|-)hh:m` zone-offset formats (supported before Spark 3.0):
   
   ```scala
   var formattedZoneId = singleHourTz.matcher(timeZoneId).replaceFirst("$10$2:")
   formattedZoneId = singleMinuteTz.matcher(formattedZoneId).replaceFirst("$1$2:0$3")
   ZoneId.of(formattedZoneId, ZoneId.SHORT_IDS)
   ```
   
   Both patterns are anchored on a leading sign character `(+|-)`. This guards the normalization so the two regexes only run when the input starts with `+` or `-`, and otherwise passes the id straight to `ZoneId.of`.
   
   ### Why are the changes needed?
   
   Region-based IDs such as `UTC`, `America/New_York`, or `GMT+8` -- the overwhelming majority of inputs -- can never match the sign-anchored patterns, yet each call still allocates two `Matcher` instances and scans the string twice before `ZoneId.of` does the real work. The guard skips those allocations for the common case. It also makes explicit that the two regexes exist only to normalize the sign-prefixed legacy formats.
   
   This is a small clarity and allocation cleanup on the shared `getZoneId` helper, not a headline performance change.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. The change is behavior-preserving: both patterns are anchored on the leading sign, so an input that does not start with `+`/`-` is returned unchanged by `replaceFirst` today, which is exactly what the guarded `else` branch returns.
   
   ### How was this patch tested?
   
   A new test in `DateTimeUtilsSuite` asserts `getZoneId` directly:
   
   - sign-prefixed offsets are still normalized (`+7:30` -> `+07:30`, `+07:3` -> `+07:03`, `-1:0` -> `-01:00`)
   - already-canonical sign offsets are unaffected (`+07:30`, `-08:00`)
   - region-based / non-sign inputs pass through unchanged (`UTC`, `Z`, `America/New_York`, and `GMT+8` -- whose `+` is not the leading character, so it must not be rewritten)
   
   The existing `getZoneId` normalization is also covered indirectly by the "string to timestamp" test. `catalyst/testOnly *DateTimeUtilsSuite` passes.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Ducc
   


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58027][SQL] Avoid unnecessary Matcher allocation in getZoneId for region-based zone IDs [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #57110:
URL: https://github.com/apache/spark/pull/57110#discussion_r3541502944


##########
sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/SparkDateTimeUtils.scala:
##########
@@ -43,10 +43,20 @@ trait SparkDateTimeUtils {
 
   def getZoneId(timeZoneId: String): ZoneId = {
     try {
-      // To support the (+|-)h:mm format because it was supported before Spark 3.0.
-      var formattedZoneId = singleHourTz.matcher(timeZoneId).replaceFirst("$10$2:")
-      // To support the (+|-)hh:m format because it was supported before Spark 3.0.
-      formattedZoneId = singleMinuteTz.matcher(formattedZoneId).replaceFirst("$1$2:0$3")
+      // The (+|-)h:mm and (+|-)hh:m formats (supported before Spark 3.0) both start with a sign

Review Comment:
   Good catch, and thanks @dongjoon-hyun , your question surfaced a real regression I missed.
   
   The two patterns are `(\+|\-)(\d):` and `(\+|\-)(\d\d):(\d)$` — neither is `^`-anchored. So the current code doesn't only normalize a leading sign offset; it also rewrites an offset that appears **after** a `GMT`/`UTC`/`UT` prefix. For example `GMT+8:00` is rewritten to `GMT+08:00`, which `ZoneId.of(..., SHORT_IDS)` then accepts. My `charAt(0) == '+'/'-'` guard skips that rewrite, so the following inputs now throw `DateTimeException` instead of resolving:
   
   - `GMT+8:00` → `GMT+08:00` (before) / throws (after)
   - `GMT-5:30`, `UTC+8:0`, `UT+8:00` — same
   
   These forms fall under the `zone_id` grammar documented in `parseTimestampString` (the `UTC+/GMT+/UT+` prefix with a `+|-hh[:]mm` suffix), so this is a user-visible behavior change, not just an untested edge. My premise for the optimization,  that the regexes only act on the leading sign, was simply wrong, and it can't be fixed by tweaking the guard without re-scanning for a mid-string `[+-]\d:`, which would negate the point.
   
   So I'm inclined to close this PR.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58027][SQL] Avoid unnecessary Matcher allocation in getZoneId for region-based zone IDs [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58027][SQL] Avoid unnecessary Matcher allocation in getZoneId for region-based zone IDs [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang closed pull request #57110: [SPARK-58027][SQL] Avoid unnecessary Matcher allocation in getZoneId for region-based zone IDs
URL: https://github.com/apache/spark/pull/57110


-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58027][SQL] Avoid unnecessary Matcher allocation in getZoneId for region-based zone IDs [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #57110:
URL: https://github.com/apache/spark/pull/57110#discussion_r3541502944


##########
sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/SparkDateTimeUtils.scala:
##########
@@ -43,10 +43,20 @@ trait SparkDateTimeUtils {
 
   def getZoneId(timeZoneId: String): ZoneId = {
     try {
-      // To support the (+|-)h:mm format because it was supported before Spark 3.0.
-      var formattedZoneId = singleHourTz.matcher(timeZoneId).replaceFirst("$10$2:")
-      // To support the (+|-)hh:m format because it was supported before Spark 3.0.
-      formattedZoneId = singleMinuteTz.matcher(formattedZoneId).replaceFirst("$1$2:0$3")
+      // The (+|-)h:mm and (+|-)hh:m formats (supported before Spark 3.0) both start with a sign

Review Comment:
   Good catch, and thanks @dongjoon-hyun , your question surfaced a real regression I missed.
   
   The two patterns are `(\+|\-)(\d):` and `(\+|\-)(\d\d):(\d)$` — neither is `^`-anchored. So the current code doesn't only normalize a leading sign offset; it also rewrites an offset that appears **after** a `GMT`/`UTC`/`UT` prefix. For example `GMT+8:00` is rewritten to `GMT+08:00`, which `ZoneId.of(..., SHORT_IDS)` then accepts. My `charAt(0) == '+'/'-'` guard skips that rewrite, so the following inputs now throw `DateTimeException` instead of resolving:
   
   - `GMT+8:00` → `GMT+08:00` (before) / throws (after)
   - `GMT-5:30`, `UTC+8:0`, `UT+8:00` — same
   
   These forms fall under the `zone_id` grammar documented in `parseTimestampString` (the `UTC+/GMT+/UT+` prefix with a `+|-hh[:]mm` suffix), so this is a user-visible behavior change, not just an untested edge. My premise for the optimization,  that the regexes only act on the leading sign — was simply wrong, and it can't be fixed by tweaking the guard without re-scanning for a mid-string `[+-]\d:`, which would negate the point.
   
   So I'm inclined to close this PR.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58027][SQL] Avoid unnecessary Matcher allocation in getZoneId for region-based zone IDs [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58027][SQL] Avoid unnecessary Matcher allocation in getZoneId for region-based zone IDs [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #57110:
URL: https://github.com/apache/spark/pull/57110#discussion_r3541364927


##########
sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/SparkDateTimeUtils.scala:
##########
@@ -43,10 +43,20 @@ trait SparkDateTimeUtils {
 
   def getZoneId(timeZoneId: String): ZoneId = {
     try {
-      // To support the (+|-)h:mm format because it was supported before Spark 3.0.
-      var formattedZoneId = singleHourTz.matcher(timeZoneId).replaceFirst("$10$2:")
-      // To support the (+|-)hh:m format because it was supported before Spark 3.0.
-      formattedZoneId = singleMinuteTz.matcher(formattedZoneId).replaceFirst("$1$2:0$3")
+      // The (+|-)h:mm and (+|-)hh:m formats (supported before Spark 3.0) both start with a sign

Review Comment:
   Although `getZoneId("GMT+8:00")` worked before, we don't support it, right?



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58027][SQL] Avoid unnecessary Matcher allocation in getZoneId for region-based zone IDs [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #57110:
URL: https://github.com/apache/spark/pull/57110#discussion_r3541268141


##########
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.

Review Comment:
   Please fix the linter error, @LuciferYang .
   
   ```
   [error] /__w/spark/spark/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeUtilsSuite.scala:365: File line length exceeds 100 characters
   ```



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58027][SQL] Avoid unnecessary Matcher allocation in getZoneId for region-based zone IDs [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #57110:
URL: https://github.com/apache/spark/pull/57110#issuecomment-4911561658

   Hmm. I removed my previous recomment because the test case was invalid in Java side. Maybe, I was confused while reading the code.
   ```
   $ jshell
   |  Welcome to JShell -- Version 25.0.3
   |  For an introduction type: /help intro
   
   jshell> java.time.ZoneId.of("GMT+08:00")
   $1 ==> GMT+08:00
   
   jshell> java.time.ZoneId.of("GMT+8:00")
   |  Exception java.time.DateTimeException: Invalid ID for offset-based ZoneId: GMT+8: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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58027][SQL] Avoid unnecessary Matcher allocation in getZoneId for region-based zone IDs [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #57110:
URL: https://github.com/apache/spark/pull/57110#discussion_r3541364927


##########
sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/SparkDateTimeUtils.scala:
##########
@@ -43,10 +43,20 @@ trait SparkDateTimeUtils {
 
   def getZoneId(timeZoneId: String): ZoneId = {
     try {
-      // To support the (+|-)h:mm format because it was supported before Spark 3.0.
-      var formattedZoneId = singleHourTz.matcher(timeZoneId).replaceFirst("$10$2:")
-      // To support the (+|-)hh:m format because it was supported before Spark 3.0.
-      formattedZoneId = singleMinuteTz.matcher(formattedZoneId).replaceFirst("$1$2:0$3")
+      // The (+|-)h:mm and (+|-)hh:m formats (supported before Spark 3.0) both start with a sign

Review Comment:
   Although `getZoneId("GMT+8:00")` worked before, we didn't support it, right?



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58027][SQL] Avoid unnecessary Matcher allocation in getZoneId for region-based zone IDs [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #57110:
URL: https://github.com/apache/spark/pull/57110#discussion_r3541502944


##########
sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/SparkDateTimeUtils.scala:
##########
@@ -43,10 +43,20 @@ trait SparkDateTimeUtils {
 
   def getZoneId(timeZoneId: String): ZoneId = {
     try {
-      // To support the (+|-)h:mm format because it was supported before Spark 3.0.
-      var formattedZoneId = singleHourTz.matcher(timeZoneId).replaceFirst("$10$2:")
-      // To support the (+|-)hh:m format because it was supported before Spark 3.0.
-      formattedZoneId = singleMinuteTz.matcher(formattedZoneId).replaceFirst("$1$2:0$3")
+      // The (+|-)h:mm and (+|-)hh:m formats (supported before Spark 3.0) both start with a sign

Review Comment:
   Good catch, and thanks @dongjoon-hyun , your question surfaced a real regression I missed.
   
   The two patterns are `(\+|\-)(\d):` and `(\+|\-)(\d\d):(\d)$` — neither is `^`-anchored. So the current code doesn't only normalize a leading sign offset; it also rewrites an offset that appears **after** a `GMT`/`UTC`/`UT` prefix. For example `GMT+8:00` is rewritten to `GMT+08:00`, which `ZoneId.of(..., SHORT_IDS)` then accepts. My `charAt(0) == '+'/'-'` guard skips that rewrite, so the following inputs now throw `DateTimeException` instead of resolving:
   
   - `GMT+8:00` → `GMT+08:00` (before) / throws (after)
   - `GMT-5:30`, `UTC+8:0`, `UT+8:00` — same
   
   These forms fall under the `zone_id` grammar documented in `parseTimestampString` (the `UTC+/GMT+/UT+` prefix with a `+|-hh[:]mm` suffix), so this is a user-visible behavior change, not just an untested edge. My premise for the optimization — that the regexes only act on the leading sign — was simply wrong, and it can't be fixed by tweaking the guard without re-scanning for a mid-string `[+-]\d:`, which would negate the point.
   
   So I'm inclined to close this PR.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-58027][SQL] Avoid unnecessary Matcher allocation in getZoneId for region-based zone IDs [spark]

Posted by "LuciferYang (via GitHub)" <gi...@apache.org>.
LuciferYang commented on code in PR #57110:
URL: https://github.com/apache/spark/pull/57110#discussion_r3541502944


##########
sql/api/src/main/scala/org/apache/spark/sql/catalyst/util/SparkDateTimeUtils.scala:
##########
@@ -43,10 +43,20 @@ trait SparkDateTimeUtils {
 
   def getZoneId(timeZoneId: String): ZoneId = {
     try {
-      // To support the (+|-)h:mm format because it was supported before Spark 3.0.
-      var formattedZoneId = singleHourTz.matcher(timeZoneId).replaceFirst("$10$2:")
-      // To support the (+|-)hh:m format because it was supported before Spark 3.0.
-      formattedZoneId = singleMinuteTz.matcher(formattedZoneId).replaceFirst("$1$2:0$3")
+      // The (+|-)h:mm and (+|-)hh:m formats (supported before Spark 3.0) both start with a sign

Review Comment:
   Good catch, and thanks — your question surfaced a real regression I missed.
   
   The two patterns are `(\+|\-)(\d):` and `(\+|\-)(\d\d):(\d)$` — neither is `^`-anchored. So the current code doesn't only normalize a leading sign offset; it also rewrites an offset that appears **after** a `GMT`/`UTC`/`UT` prefix. For example `GMT+8:00` is rewritten to `GMT+08:00`, which `ZoneId.of(..., SHORT_IDS)` then accepts. My `charAt(0) == '+'/'-'` guard skips that rewrite, so the following inputs now throw `DateTimeException` instead of resolving:
   
   - `GMT+8:00` → `GMT+08:00` (before) / throws (after)
   - `GMT-5:30`, `UTC+8:0`, `UT+8:00` — same
   
   These forms fall under the `zone_id` grammar documented in `parseTimestampString` (the `UTC+/GMT+/UT+` prefix with a `+|-hh[:]mm` suffix), so this is a user-visible behavior change, not just an untested edge. My premise for the optimization — that the regexes only act on the leading sign — was simply wrong, and it can't be fixed by tweaking the guard without re-scanning for a mid-string `[+-]\d:`, which would negate the point.
   
   So I'm inclined to close this PR.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org