This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.2 by this push:
     new 9bfa6ebc885 [fix](timezone)(branch-4.2) Normalize zero-offset time 
zones for ORC readers (#69125)
9bfa6ebc885 is described below

commit 9bfa6ebc8852716c3f72795087e6cc833eaed39c
Author: Gabriel <[email protected]>
AuthorDate: Fri Oct 16 14:08:41 2026 +0800

    [fix](timezone)(branch-4.2) Normalize zero-offset time zones for ORC 
readers (#69125)
    
    ### What problem does this PR solve?
    
    Related PR: #68865, #69123
    
    On `branch-4.2`, a session time zone of `+00:00` or `-00:00` is
    canonicalized by Java to `Z`. ORC treats that value as a zoneinfo
    filename, so reading an ORC file fails with `Can't open
    /usr/share/zoneinfo/Z`.
    
    Adapt the zero-offset normalization from #68865 to the existing shared
    FE helper: send `UTC` for fixed zero-offset zones while preserving
    nonzero offsets, aliases, and regional historical/DST rules. All
    existing callers of the helper receive the corrected identifier.
    
    ### Release note
    
    Fix ORC reads failing when the session time zone is a zero offset such
    as `+00:00`.
    
    ### Check List (For Author)
    
    - Test
        - [x] Unit Test
        - [x] Manual test
    
    Validation:
    - Recompiled `TimeUtils` and `TimeUtilsTest` against prebuilt FE
    dependencies and ran JUnitCore: all 10 tests passed. Before the fix, the
    new zero-offset test failed with expected `UTC`, actual `Z`.
    - Coverage includes standardized `+0:00`/`-0:00`, fixed zero-offset
    names, nonzero fractional offsets, aliases, DST regions, and a region
    with historical offset changes.
    - FE Checkstyle: `mvn -o -B -pl fe-core -am checkstyle:check`.
    - An isolated ORC library probe reproduced the `Z` failure and read the
    same synthetic ORC file successfully with `UTC`.
    - A full Doris build and SQL end-to-end regression were not run locally;
    CI is requested separately.
    
    - Behavior changed:
    - [x] Yes. Fixed zero-offset zones are sent to execution backends as
    `UTC`.
    - Does this need documentation?
        - [x] No.
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label
---
 .../org/apache/doris/common/util/TimeUtils.java    |  6 +++++-
 .../apache/doris/common/util/TimeUtilsTest.java    | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/common/util/TimeUtils.java 
b/fe/fe-core/src/main/java/org/apache/doris/common/util/TimeUtils.java
index 565bc25cc66..c808c17b52a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/TimeUtils.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/TimeUtils.java
@@ -39,6 +39,7 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.ZoneId;
+import java.time.ZoneOffset;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeParseException;
 import java.time.temporal.ChronoField;
@@ -150,7 +151,10 @@ public class TimeUtils {
 
     /** Resolve a Doris time-zone name to the canonical ID understood by 
execution backends. */
     public static String getCanonicalTimeZone(String timeZone) {
-        return ZoneId.of(timeZone, timeZoneAliasMap).getId();
+        ZoneId zoneId = ZoneId.of(timeZone, timeZoneAliasMap);
+        // Java renders zero offsets as Z, which ORC cannot resolve as a 
time-zone file.
+        // Normalize only fixed zero offsets so regional historical and DST 
rules are preserved.
+        return zoneId.normalized().equals(ZoneOffset.UTC) ? UTC_TIME_ZONE : 
zoneId.getId();
     }
 
     public static TimeZone getUTCTimeZone() {
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/common/util/TimeUtilsTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/common/util/TimeUtilsTest.java
index 3cb5f696240..f6fd8c21dba 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/common/util/TimeUtilsTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/common/util/TimeUtilsTest.java
@@ -181,6 +181,28 @@ public class TimeUtilsTest {
         }
     }
 
+    @Test
+    public void testCanonicalZeroOffsetTimeZone() throws DdlException {
+        for (String timeZone : new String[] {"+00:00", "-00:00", "UTC", "GMT", 
"UTC+00:00",
+                "GMT+00:00", "GMT-00:00", "Etc/UTC", "Etc/GMT", "Z"}) {
+            Assert.assertEquals(timeZone, "UTC", 
TimeUtils.getCanonicalTimeZone(timeZone));
+        }
+        Assert.assertEquals("UTC", TimeUtils.getCanonicalTimeZone(
+                TimeUtils.checkTimeZoneValidAndStandardize("+0:00")));
+        Assert.assertEquals("UTC", TimeUtils.getCanonicalTimeZone(
+                TimeUtils.checkTimeZoneValidAndStandardize("-0:00")));
+    }
+
+    @Test
+    public void testCanonicalTimeZonePreservesNonZeroOffsetsAndRegionRules() {
+        for (String timeZone : new String[] {"+08:00", "-05:00", "+00:30", 
"-00:30",
+                "UTC+08:00", "GMT-05:00", "Asia/Shanghai", "Europe/London", 
"Africa/Abidjan"}) {
+            Assert.assertEquals(timeZone, timeZone, 
TimeUtils.getCanonicalTimeZone(timeZone));
+        }
+        Assert.assertEquals("Asia/Shanghai", 
TimeUtils.getCanonicalTimeZone("CST"));
+        Assert.assertEquals("-05:00", TimeUtils.getCanonicalTimeZone("EST"));
+    }
+
     @Test
     public void testGetHourAsDate() {
         Calendar calendar = Calendar.getInstance();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to