You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2026/04/26 18:01:23 UTC

(doris) branch master updated: [improvement](be) Optimize parquet timestamp convert path (#62559)

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

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 5f84cfce257 [improvement](be) Optimize parquet timestamp convert path (#62559)
5f84cfce257 is described below

commit 5f84cfce257eeb2e25c4fc2bd6c926e36dec4228
Author: Socrates <su...@selectdb.com>
AuthorDate: Mon Apr 27 02:01:15 2026 +0800

    [improvement](be) Optimize parquet timestamp convert path (#62559)
    
    ### What problem does this PR solve?
    
    Issue Number: N/A
    
    Related PR: N/A
    
    Problem Summary:
    
    Parquet timestamp conversion is a scan hotspot, but the previous
    implementation still paid extra per-row timezone conversion cost and the
    runtime profile did not expose enough detail to isolate where the time
    was spent.
    
    This PR updates the Parquet timestamp convert path and its supporting
    coverage:
    
    1. Add finer-grained Parquet reader profile timers so convert, column
    read IO, and fill-columns work are visible separately in runtime profile
    output.
    2. Rework Parquet timestamp conversion to use a faster path for
    fixed-offset timezones and a lighter lookup-offset path for named
    timezones, while preserving the original fallback path for correctness.
    3. Extend timezone handling and add BE unit tests for fixed-offset
    detection, timezone normalization, and Parquet timestamp conversion
    behavior.
    4. Add Hive external regression coverage for Parquet timestamp reads
    across equivalent timezone spellings and named timezones.
    5. Remove the temporary design note from the repository.
---
 be/src/format/parquet/parquet_column_convert.h     | 104 +++++++++++++-
 be/src/format/parquet/vparquet_column_reader.cpp   |   8 +-
 be/src/format/parquet/vparquet_column_reader.h     |  11 +-
 be/src/format/parquet/vparquet_reader.cpp          |   3 +
 be/src/format/parquet/vparquet_reader.h            |   1 +
 be/src/util/timezone_utils.cpp                     | 126 +++++++++++++++--
 be/src/util/timezone_utils.h                       |   5 +
 .../format/parquet/parquet_column_convert_test.cpp | 122 ++++++++++++++++
 be/test/util/timezone_utils_test.cpp               | 155 ++++++++++++++-------
 .../hive/test_hive_date_timezone.groovy            |  29 ++++
 10 files changed, 493 insertions(+), 71 deletions(-)

diff --git a/be/src/format/parquet/parquet_column_convert.h b/be/src/format/parquet/parquet_column_convert.h
index 1f319745b8f..f56ad295bab 100644
--- a/be/src/format/parquet/parquet_column_convert.h
+++ b/be/src/format/parquet/parquet_column_convert.h
@@ -17,7 +17,12 @@
 
 #pragma once
 
+#include <cctz/time_zone.h>
 #include <gen_cpp/parquet_types.h>
+#include <libdivide.h>
+
+#include <chrono>
+#include <limits>
 
 #include "common/cast_set.h"
 #include "core/column/column_varbinary.h"
@@ -31,13 +36,86 @@
 #include "format/parquet/decoder.h"
 #include "format/parquet/parquet_common.h"
 #include "format/parquet/schema_desc.h"
+#include "util/timezone_utils.h"
 
 namespace doris::parquet {
+namespace detail {
+
+inline bool try_split_local_time(int64_t local_time, uint16_t* year, uint8_t* month, uint8_t* day,
+                                 uint8_t* hour, uint8_t* minute, uint8_t* second) {
+    static const libdivide::divider<int64_t> fast_div_86400(86400);
+    static const libdivide::divider<int64_t> fast_div_3600(3600);
+    static const libdivide::divider<int64_t> fast_div_60(60);
+    static constexpr int64_t kMinSupportedDays = -365LL * 10000;
+    static constexpr int64_t kMaxSupportedDays = 365LL * 10000;
+
+    int64_t days = local_time / fast_div_86400;
+    int64_t second_of_day = local_time - days * 86400;
+    if (second_of_day < 0) {
+        second_of_day += 86400;
+        --days;
+    }
+    if (days < kMinSupportedDays || days > kMaxSupportedDays) {
+        return false;
+    }
+
+    const auto ymd = std::chrono::year_month_day {std::chrono::sys_days {std::chrono::days {days}}};
+    const int y = static_cast<int>(ymd.year());
+    if (y < 0 || y > std::numeric_limits<uint16_t>::max()) {
+        return false;
+    }
+
+    const int64_t h = second_of_day / fast_div_3600;
+    const int64_t minute_second = second_of_day - h * 3600;
+    const int64_t m = minute_second / fast_div_60;
+    const int64_t s = minute_second - m * 60;
+
+    *year = static_cast<uint16_t>(y);
+    *month = static_cast<uint8_t>(static_cast<unsigned>(ymd.month()));
+    *day = static_cast<uint8_t>(static_cast<unsigned>(ymd.day()));
+    *hour = static_cast<uint8_t>(h);
+    *minute = static_cast<uint8_t>(m);
+    *second = static_cast<uint8_t>(s);
+    return true;
+}
+
+template <typename DateType>
+inline bool try_convert_timestamp_with_fixed_offset(DateType& value, int64_t epoch_seconds,
+                                                    int32_t offset_seconds) {
+    uint16_t year = 0;
+    uint8_t month = 0;
+    uint8_t day = 0;
+    uint8_t hour = 0;
+    uint8_t minute = 0;
+    uint8_t second = 0;
+    if (!try_split_local_time(epoch_seconds + offset_seconds, &year, &month, &day, &hour, &minute,
+                              &second)) {
+        return false;
+    }
+    // The caller sets sub-second precision immediately after this conversion.
+    value.unchecked_set_time(year, month, day, hour, minute, second, 0);
+    return true;
+}
+
+template <typename DateType>
+inline bool try_convert_timestamp_with_lookup(DateType& value, int64_t epoch_seconds,
+                                              const cctz::time_zone& ctz) {
+    static const auto epoch = std::chrono::time_point_cast<cctz::sys_seconds>(
+            std::chrono::system_clock::from_time_t(0));
+    cctz::time_point<cctz::sys_seconds> t = epoch + cctz::seconds(epoch_seconds);
+    const int32_t offset = ctz.lookup_offset(t).offset;
+    return try_convert_timestamp_with_fixed_offset(value, epoch_seconds, offset);
+}
+
+} // namespace detail
+
 struct ConvertParams {
     // schema.logicalType.TIMESTAMP.isAdjustedToUTC == false
     static const cctz::time_zone utc0;
     // schema.logicalType.TIMESTAMP.isAdjustedToUTC == true, we should set local time zone
     const cctz::time_zone* ctz = nullptr;
+    bool is_fixed_offset = false;
+    int32_t fixed_offset_seconds = 0;
     int64_t second_mask = 1;
     int64_t scale_to_nano_factor = 1;
     const FieldSchema* field_schema = nullptr;
@@ -108,6 +186,10 @@ struct ConvertParams {
             }
         }
 
+        if (ctz != nullptr) {
+            is_fixed_offset =
+                    TimezoneUtils::try_get_fixed_offset_seconds(*ctz, &fixed_offset_seconds);
+        }
         is_type_compatibility = field_schema_->is_type_compatibility;
     }
 };
@@ -658,7 +740,16 @@ struct Int64ToTimestamp : public PhysicalToLogicalConverter {
             int64_t x = src_data[i];
             auto& num = data[start_idx + i];
             auto& value = reinterpret_cast<DateV2Value<DateTimeV2ValueType>&>(num);
-            value.from_unixtime(x / _convert_params->second_mask, *_convert_params->ctz);
+            const int64_t epoch_seconds = x / _convert_params->second_mask;
+            if (_convert_params->is_fixed_offset) {
+                if (!detail::try_convert_timestamp_with_fixed_offset(
+                            value, epoch_seconds, _convert_params->fixed_offset_seconds)) {
+                    value.from_unixtime(epoch_seconds, *_convert_params->ctz);
+                }
+            } else if (!detail::try_convert_timestamp_with_lookup(value, epoch_seconds,
+                                                                  *_convert_params->ctz)) {
+                value.from_unixtime(epoch_seconds, *_convert_params->ctz);
+            }
             value.set_microsecond((x % _convert_params->second_mask) *
                                   (_convert_params->scale_to_nano_factor / 1000));
         }
@@ -708,7 +799,16 @@ struct Int96toTimestamp : public PhysicalToLogicalConverter {
                     reinterpret_cast<DateV2Value<DateTimeV2ValueType>&>(data[start_idx + i]);
 
             int64_t timestamp_with_micros = src_cell_data.to_timestamp_micros();
-            dst_value.from_unixtime(timestamp_with_micros / 1000000, *_convert_params->ctz);
+            const int64_t epoch_seconds = timestamp_with_micros / 1000000;
+            if (_convert_params->is_fixed_offset) {
+                if (!detail::try_convert_timestamp_with_fixed_offset(
+                            dst_value, epoch_seconds, _convert_params->fixed_offset_seconds)) {
+                    dst_value.from_unixtime(epoch_seconds, *_convert_params->ctz);
+                }
+            } else if (!detail::try_convert_timestamp_with_lookup(dst_value, epoch_seconds,
+                                                                  *_convert_params->ctz)) {
+                dst_value.from_unixtime(epoch_seconds, *_convert_params->ctz);
+            }
             dst_value.set_microsecond(timestamp_with_micros % 1000000);
         }
         return Status::OK();
diff --git a/be/src/format/parquet/vparquet_column_reader.cpp b/be/src/format/parquet/vparquet_column_reader.cpp
index a221d29abd9..ba7d42a5aed 100644
--- a/be/src/format/parquet/vparquet_column_reader.cpp
+++ b/be/src/format/parquet/vparquet_column_reader.cpp
@@ -636,8 +636,12 @@ Status ScalarColumnReader<IN_COLLECTION, OFFSET_INDEX>::read_column_data(
         }
     }
 
-    return _converter->convert(resolved_column, _field_schema->data_type, type, doris_column,
-                               is_dict_filter);
+    {
+        SCOPED_RAW_TIMER(&_convert_time);
+        RETURN_IF_ERROR(_converter->convert(resolved_column, _field_schema->data_type, type,
+                                            doris_column, is_dict_filter));
+    }
+    return Status::OK();
 }
 
 Status ArrayColumnReader::init(std::unique_ptr<ParquetColumnReader> element_reader,
diff --git a/be/src/format/parquet/vparquet_column_reader.h b/be/src/format/parquet/vparquet_column_reader.h
index a8716b8f9c8..9d9fd2280c8 100644
--- a/be/src/format/parquet/vparquet_column_reader.h
+++ b/be/src/format/parquet/vparquet_column_reader.h
@@ -65,6 +65,7 @@ public:
                   decode_dict_time(0),
                   decode_level_time(0),
                   decode_null_map_time(0),
+                  convert_time(0),
                   skip_page_header_num(0),
                   parse_page_header_num(0),
                   read_page_header_time(0),
@@ -77,7 +78,8 @@ public:
                   page_cache_compressed_hit_counter(0),
                   page_cache_decompressed_hit_counter(0) {}
 
-        ColumnStatistics(ColumnChunkReaderStatistics& cs, int64_t null_map_time)
+        ColumnStatistics(ColumnChunkReaderStatistics& cs, int64_t null_map_time,
+                         int64_t convert_time_)
                 : page_index_read_calls(0),
                   decompress_time(cs.decompress_time),
                   decompress_cnt(cs.decompress_cnt),
@@ -86,6 +88,7 @@ public:
                   decode_dict_time(cs.decode_dict_time),
                   decode_level_time(cs.decode_level_time),
                   decode_null_map_time(null_map_time),
+                  convert_time(convert_time_),
                   skip_page_header_num(cs.skip_page_header_num),
                   parse_page_header_num(cs.parse_page_header_num),
                   read_page_header_time(cs.read_page_header_time),
@@ -106,6 +109,7 @@ public:
         int64_t decode_dict_time;
         int64_t decode_level_time;
         int64_t decode_null_map_time;
+        int64_t convert_time;
         int64_t skip_page_header_num;
         int64_t parse_page_header_num;
         int64_t read_page_header_time;
@@ -127,6 +131,7 @@ public:
             decode_dict_time += col_statistics.decode_dict_time;
             decode_level_time += col_statistics.decode_level_time;
             decode_null_map_time += col_statistics.decode_null_map_time;
+            convert_time += col_statistics.convert_time;
             skip_page_header_num += col_statistics.skip_page_header_num;
             parse_page_header_num += col_statistics.parse_page_header_num;
             read_page_header_time += col_statistics.read_page_header_time;
@@ -225,7 +230,8 @@ public:
     const std::vector<level_t>& get_rep_level() const override { return _rep_levels; }
     const std::vector<level_t>& get_def_level() const override { return _def_levels; }
     ColumnStatistics column_statistics() override {
-        return ColumnStatistics(_chunk_reader->chunk_statistics(), _decode_null_map_time);
+        return ColumnStatistics(_chunk_reader->chunk_statistics(), _decode_null_map_time,
+                                _convert_time);
     }
     void close() override {}
 
@@ -311,6 +317,7 @@ private:
     std::unique_ptr<parquet::PhysicalToLogicalConverter> _converter = nullptr;
     std::unique_ptr<std::vector<uint8_t>> _nested_filter_map_data = nullptr;
     size_t _orig_filter_map_index = 0;
+    int64_t _convert_time = 0;
 
     Status _skip_values(size_t num_values);
     Status _read_values(size_t num_values, ColumnPtr& doris_column, DataTypePtr& type,
diff --git a/be/src/format/parquet/vparquet_reader.cpp b/be/src/format/parquet/vparquet_reader.cpp
index 0da63c40544..d5d3fba18b2 100644
--- a/be/src/format/parquet/vparquet_reader.cpp
+++ b/be/src/format/parquet/vparquet_reader.cpp
@@ -276,6 +276,8 @@ void ParquetReader::_init_profile() {
                 ADD_CHILD_TIMER_WITH_LEVEL(_profile, "PredicateFilterTime", parquet_profile, 1);
         _parquet_profile.dict_filter_rewrite_time =
                 ADD_CHILD_TIMER_WITH_LEVEL(_profile, "DictFilterRewriteTime", parquet_profile, 1);
+        _parquet_profile.convert_time =
+                ADD_CHILD_TIMER_WITH_LEVEL(_profile, "ConvertTime", parquet_profile, 1);
         _parquet_profile.bloom_filter_read_time =
                 ADD_CHILD_TIMER_WITH_LEVEL(_profile, "BloomFilterReadTime", parquet_profile, 1);
     }
@@ -1484,6 +1486,7 @@ void ParquetReader::_collect_profile() {
                    _reader_statistics.predicate_filter_time);
     COUNTER_UPDATE(_parquet_profile.dict_filter_rewrite_time,
                    _reader_statistics.dict_filter_rewrite_time);
+    COUNTER_UPDATE(_parquet_profile.convert_time, _column_statistics.convert_time);
     COUNTER_UPDATE(_parquet_profile.bloom_filter_read_time,
                    _reader_statistics.bloom_filter_read_time);
     COUNTER_UPDATE(_parquet_profile.page_index_read_calls,
diff --git a/be/src/format/parquet/vparquet_reader.h b/be/src/format/parquet/vparquet_reader.h
index 0bb200ba229..fd6785b2600 100644
--- a/be/src/format/parquet/vparquet_reader.h
+++ b/be/src/format/parquet/vparquet_reader.h
@@ -284,6 +284,7 @@ private:
         RuntimeProfile::Counter* parse_page_header_num = nullptr;
         RuntimeProfile::Counter* predicate_filter_time = nullptr;
         RuntimeProfile::Counter* dict_filter_rewrite_time = nullptr;
+        RuntimeProfile::Counter* convert_time = nullptr;
         RuntimeProfile::Counter* bloom_filter_read_time = nullptr;
     };
 
diff --git a/be/src/util/timezone_utils.cpp b/be/src/util/timezone_utils.cpp
index 556012aae80..b575ed7a29f 100644
--- a/be/src/util/timezone_utils.cpp
+++ b/be/src/util/timezone_utils.cpp
@@ -28,12 +28,16 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include <algorithm>
 #include <boost/algorithm/string.hpp>
 #include <boost/algorithm/string/case_conv.hpp>
+#include <cctype>
+#include <chrono>
 #include <cstdlib>
 #include <filesystem>
 #include <memory>
 #include <string>
+#include <string_view>
 
 #include "common/exception.h"
 #include "common/logging.h"
@@ -160,26 +164,124 @@ bool TimezoneUtils::find_cctz_time_zone(const std::string& timezone, cctz::time_
         ctz = it->second;
         return true;
     }
+
+    std::string normalized;
+    if (!normalize_timezone_name(timezone, &normalized)) {
+        return false;
+    }
+    if (auto it = lower_zone_cache_->find(to_lower_copy(normalized));
+        it != lower_zone_cache_->end()) [[likely]] {
+        ctz = it->second;
+        return true;
+    }
+    return parse_tz_offset_string(normalized, ctz);
+}
+
+bool TimezoneUtils::try_get_fixed_offset_seconds(const cctz::time_zone& timezone,
+                                                 int32_t* offset_seconds) {
+    const std::string& timezone_name = timezone.name();
+    if (timezone_name == "UTC" || timezone_name == "Etc/UTC" || timezone_name == "Etc/GMT") {
+        *offset_seconds = 0;
+        return true;
+    }
+
+    // cctz names fixed_time_zone() instances with the "Fixed/" prefix. TZDB's Etc/GMT*
+    // zones are fixed offsets too; cctz handles their POSIX-style reversed sign in lookup_offset().
+    // If this naming convention changes, falling through to the generic path remains correct.
+    static const auto epoch = std::chrono::time_point_cast<cctz::sys_seconds>(
+            std::chrono::system_clock::from_time_t(0));
+    if (timezone_name.compare(0, 6, "Fixed/") == 0 || timezone_name.compare(0, 7, "Etc/GMT") == 0) {
+        *offset_seconds = timezone.lookup_offset(epoch).offset;
+        return true;
+    }
     return false;
 }
 
-bool TimezoneUtils::parse_tz_offset_string(const std::string& timezone, cctz::time_zone& ctz) {
-    // like +08:00, which not in timezone_names_map_
-    re2::StringPiece value;
-    if (time_zone_offset_format_reg.Match(timezone, 0, timezone.size(), RE2::UNANCHORED, &value, 1))
-            [[likely]] {
-        bool positive = value[0] != '-';
+static bool normalize_offset_string(const std::string& timezone, bool allow_hour_only,
+                                    std::string* normalized) {
+    if (timezone.size() < 2 || (timezone[0] != '+' && timezone[0] != '-')) {
+        return false;
+    }
+
+    const bool positive = timezone[0] == '+';
+    const std::string_view rest(timezone.data() + 1, timezone.size() - 1);
+    int hour = 0;
+    int minute = 0;
 
-        //Regular expression guarantees hour and minute must be int
-        int hour = std::stoi(value.substr(1, 2).as_string());
-        int minute = std::stoi(value.substr(4, 2).as_string());
+    const auto parse_digit = [](char c) -> int { return c - '0'; };
+    const auto is_two_digits = [](std::string_view value) -> bool {
+        return value.size() == 2 && std::isdigit(static_cast<unsigned char>(value[0])) &&
+               std::isdigit(static_cast<unsigned char>(value[1]));
+    };
+    const auto is_one_or_two_digits = [](std::string_view value) -> bool {
+        return (value.size() == 1 || value.size() == 2) &&
+               std::all_of(value.begin(), value.end(),
+                           [](char c) { return std::isdigit(static_cast<unsigned char>(c)); });
+    };
 
-        // timezone offsets around the world extended from -12:00 to +14:00
-        if (!positive && hour > 12) {
+    auto colon_pos = rest.find(':');
+    if (colon_pos != std::string_view::npos) {
+        std::string_view hour_part = rest.substr(0, colon_pos);
+        std::string_view minute_part = rest.substr(colon_pos + 1);
+        if (!is_one_or_two_digits(hour_part) || !is_two_digits(minute_part)) {
             return false;
-        } else if (positive && hour > 14) {
+        }
+        hour = std::stoi(std::string(hour_part));
+        minute = parse_digit(minute_part[0]) * 10 + parse_digit(minute_part[1]);
+    } else {
+        if (!allow_hour_only || !is_one_or_two_digits(rest)) {
             return false;
         }
+        hour = std::stoi(std::string(rest));
+        minute = 0;
+    }
+
+    if ((!positive && hour > 12) || (positive && hour > 14) || minute >= 60) {
+        return false;
+    }
+
+    *normalized = std::string(1, positive ? '+' : '-') + (hour < 10 ? "0" : "") +
+                  std::to_string(hour) + ":" + (minute < 10 ? "0" : "") + std::to_string(minute);
+    return true;
+}
+
+bool TimezoneUtils::normalize_timezone_name(const std::string& timezone, std::string* normalized) {
+    const std::string lower = to_lower_copy(timezone);
+    if (lower == "utc" || lower == "etc/utc" || lower == "zulu") {
+        *normalized = "UTC";
+        return true;
+    }
+
+    if (lower.rfind("utc", 0) == 0 || lower.rfind("gmt", 0) == 0) {
+        if (timezone.size() <= 3) {
+            return false;
+        }
+        return normalize_offset_string(timezone.substr(3), true, normalized);
+    }
+
+    if (!timezone.empty() && (timezone[0] == '+' || timezone[0] == '-')) {
+        return normalize_offset_string(timezone, false, normalized);
+    }
+
+    return false;
+}
+
+bool TimezoneUtils::parse_tz_offset_string(const std::string& timezone, cctz::time_zone& ctz) {
+    std::string normalized;
+    if (!normalize_timezone_name(timezone, &normalized)) {
+        return false;
+    }
+    if (normalized == "UTC") {
+        ctz = cctz::utc_time_zone();
+        return true;
+    }
+
+    re2::StringPiece value;
+    if (time_zone_offset_format_reg.Match(normalized, 0, normalized.size(), RE2::UNANCHORED, &value,
+                                          1)) [[likely]] {
+        const bool positive = value[0] != '-';
+        const int hour = std::stoi(value.substr(1, 2).as_string());
+        const int minute = std::stoi(value.substr(4, 2).as_string());
         int offset = hour * 60 * 60 + minute * 60;
         offset *= positive ? 1 : -1;
         ctz = cctz::fixed_time_zone(cctz::seconds(offset));
diff --git a/be/src/util/timezone_utils.h b/be/src/util/timezone_utils.h
index c62851bece9..3ae0a23d1d1 100644
--- a/be/src/util/timezone_utils.h
+++ b/be/src/util/timezone_utils.h
@@ -36,6 +36,9 @@ public:
 
     static bool find_cctz_time_zone(const std::string& timezone, cctz::time_zone& ctz);
 
+    static bool try_get_fixed_offset_seconds(const cctz::time_zone& timezone,
+                                             int32_t* offset_seconds);
+
     static const std::string default_time_zone;
 
 private:
@@ -45,6 +48,8 @@ private:
 
     static void load_offsets_to_cache();
 
+    static bool normalize_timezone_name(const std::string& timezone, std::string* normalized);
+
     static bool parse_tz_offset_string(const std::string& timezone, cctz::time_zone& ctz);
 };
 } // namespace doris
diff --git a/be/test/format/parquet/parquet_column_convert_test.cpp b/be/test/format/parquet/parquet_column_convert_test.cpp
new file mode 100644
index 00000000000..e50d28ef0e7
--- /dev/null
+++ b/be/test/format/parquet/parquet_column_convert_test.cpp
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "format/parquet/parquet_column_convert.h"
+
+#include <cctz/time_zone.h>
+
+#include <chrono>
+#include <vector>
+
+#include "util/timezone_utils.h"
+
+namespace doris::parquet {
+
+static FieldSchema make_timestamp_field_schema(bool is_adjusted_to_utc) {
+    FieldSchema field_schema;
+    field_schema.parquet_schema.__set_name("ts");
+    field_schema.parquet_schema.__set_logicalType(tparquet::LogicalType());
+    field_schema.parquet_schema.logicalType.__set_TIMESTAMP(tparquet::TimestampType());
+    field_schema.parquet_schema.logicalType.TIMESTAMP.__set_isAdjustedToUTC(is_adjusted_to_utc);
+    field_schema.parquet_schema.logicalType.TIMESTAMP.__set_unit(tparquet::TimeUnit());
+    field_schema.parquet_schema.logicalType.TIMESTAMP.unit.__set_MICROS(tparquet::MicroSeconds());
+    return field_schema;
+}
+
+TEST(ParquetColumnConvertTest, InitFixedOffsetDetection) {
+    cctz::time_zone utc_tz;
+    cctz::time_zone plus8_tz;
+    cctz::time_zone shanghai_tz;
+
+    ASSERT_TRUE(TimezoneUtils::find_cctz_time_zone("UTC", utc_tz));
+    ASSERT_TRUE(TimezoneUtils::find_cctz_time_zone("+8:00", plus8_tz));
+    ASSERT_TRUE(TimezoneUtils::find_cctz_time_zone("Asia/Shanghai", shanghai_tz));
+
+    auto adjusted_field = make_timestamp_field_schema(true);
+    ConvertParams utc_params;
+    utc_params.init(&adjusted_field, &utc_tz);
+    EXPECT_TRUE(utc_params.is_fixed_offset);
+    EXPECT_EQ(0, utc_params.fixed_offset_seconds);
+
+    ConvertParams plus8_params;
+    plus8_params.init(&adjusted_field, &plus8_tz);
+    EXPECT_TRUE(plus8_params.is_fixed_offset);
+    EXPECT_EQ(8 * 3600, plus8_params.fixed_offset_seconds);
+
+    ConvertParams shanghai_params;
+    shanghai_params.init(&adjusted_field, &shanghai_tz);
+    EXPECT_FALSE(shanghai_params.is_fixed_offset);
+
+    auto non_adjusted_field = make_timestamp_field_schema(false);
+    ConvertParams non_adjusted_params;
+    non_adjusted_params.init(&non_adjusted_field, &shanghai_tz);
+    EXPECT_TRUE(non_adjusted_params.is_fixed_offset);
+    EXPECT_EQ(0, non_adjusted_params.fixed_offset_seconds);
+}
+
+TEST(ParquetColumnConvertTest, FixedOffsetPathMatchesOriginal) {
+    struct TestCase {
+        int64_t timestamp;
+        int32_t offset_seconds;
+    };
+    const std::vector<TestCase> test_cases {
+            {.timestamp = 0, .offset_seconds = 0},
+            {.timestamp = -1, .offset_seconds = 0},
+            {.timestamp = -1, .offset_seconds = 8 * 3600},
+            {.timestamp = 1713249600, .offset_seconds = 8 * 3600},
+            {.timestamp = 1713249600, .offset_seconds = -(6 * 3600)},
+            {.timestamp = 1713249600, .offset_seconds = 5 * 3600 + 45 * 60},
+    };
+
+    for (const auto& test_case : test_cases) {
+        DateV2Value<DateTimeV2ValueType> fast_value;
+        DateV2Value<DateTimeV2ValueType> original_value;
+        const auto timezone = cctz::fixed_time_zone(cctz::seconds(test_case.offset_seconds));
+
+        ASSERT_TRUE(detail::try_convert_timestamp_with_fixed_offset(fast_value, test_case.timestamp,
+                                                                    test_case.offset_seconds));
+        original_value.from_unixtime(test_case.timestamp, timezone);
+
+        EXPECT_EQ(original_value.to_date_int_val(), fast_value.to_date_int_val());
+    }
+}
+
+TEST(ParquetColumnConvertTest, LookupPathMatchesOriginal) {
+    cctz::time_zone shanghai_tz;
+    cctz::time_zone new_york_tz;
+    ASSERT_TRUE(cctz::load_time_zone("Asia/Shanghai", &shanghai_tz));
+    ASSERT_TRUE(cctz::load_time_zone("America/New_York", &new_york_tz));
+
+    const std::vector<int64_t> timestamps {0, -1, 1710053940, 1710054060, 541526400};
+
+    for (const auto timestamp : timestamps) {
+        DateV2Value<DateTimeV2ValueType> lookup_value;
+        DateV2Value<DateTimeV2ValueType> original_value;
+
+        ASSERT_TRUE(
+                detail::try_convert_timestamp_with_lookup(lookup_value, timestamp, shanghai_tz));
+        original_value.from_unixtime(timestamp, shanghai_tz);
+        EXPECT_EQ(original_value.to_date_int_val(), lookup_value.to_date_int_val());
+
+        ASSERT_TRUE(
+                detail::try_convert_timestamp_with_lookup(lookup_value, timestamp, new_york_tz));
+        original_value.from_unixtime(timestamp, new_york_tz);
+        EXPECT_EQ(original_value.to_date_int_val(), lookup_value.to_date_int_val());
+    }
+}
+
+} // namespace doris::parquet
diff --git a/be/test/util/timezone_utils_test.cpp b/be/test/util/timezone_utils_test.cpp
index 06ad0b37048..6b556307eb5 100644
--- a/be/test/util/timezone_utils_test.cpp
+++ b/be/test/util/timezone_utils_test.cpp
@@ -33,55 +33,61 @@ TEST(TimezoneUtilsTest, ParseOffset) {
     const auto tp = cctz::civil_second(2011, 1, 1, 0, 0,
                                        0); // offset has no DST, every time point is acceptable
     cctz::time_zone result;
+    const auto lookup_offset = [&](const cctz::time_zone& tz) {
+        return tz.lookup(cctz::convert(tp, tz)).offset;
+    };
 
-    TimezoneUtils::parse_tz_offset_string("+14:00", result);
-    auto cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, 14 * 3600);
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("+14:00", result));
+    EXPECT_EQ(lookup_offset(result), 14 * 3600);
 
-    TimezoneUtils::parse_tz_offset_string("+00:00", result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, 0 * 3600);
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("+00:00", result));
+    EXPECT_EQ(lookup_offset(result), 0);
 
-    TimezoneUtils::parse_tz_offset_string("+00:30", result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, 1800);
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("+00:30", result));
+    EXPECT_EQ(lookup_offset(result), 1800);
 
-    TimezoneUtils::parse_tz_offset_string("+10:30", result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, 10 * 3600 + 1800);
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("+10:30", result));
+    EXPECT_EQ(lookup_offset(result), 10 * 3600 + 1800);
 
-    TimezoneUtils::parse_tz_offset_string("+01:00", result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, 1 * 3600);
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("+01:00", result));
+    EXPECT_EQ(lookup_offset(result), 1 * 3600);
 
-    TimezoneUtils::parse_tz_offset_string("-12:00", result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, -12 * 3600);
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("-12:00", result));
+    EXPECT_EQ(lookup_offset(result), -12 * 3600);
 
-    TimezoneUtils::parse_tz_offset_string("-09:00", result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, -9 * 3600);
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("-09:00", result));
+    EXPECT_EQ(lookup_offset(result), -9 * 3600);
 
-    TimezoneUtils::parse_tz_offset_string("-01:00", result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, -1 * 3600);
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("-01:00", result));
+    EXPECT_EQ(lookup_offset(result), -1 * 3600);
 
-    TimezoneUtils::parse_tz_offset_string("-00:00", result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, 0 * 3600);
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("-00:00", result));
+    EXPECT_EQ(lookup_offset(result), 0);
 
-    TimezoneUtils::parse_tz_offset_string("-00:30", result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, -1800);
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("-00:30", result));
+    EXPECT_EQ(lookup_offset(result), -1800);
 
-    TimezoneUtils::parse_tz_offset_string("-10:30", result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, -10 * 3600 - 1800);
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("-10:30", result));
+    EXPECT_EQ(lookup_offset(result), -10 * 3600 - 1800);
+
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("+9:30", result));
+    EXPECT_EQ(lookup_offset(result), 9 * 3600 + 1800);
+
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("UTC+8", result));
+    EXPECT_EQ(lookup_offset(result), 8 * 3600);
+
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("GMT-06:30", result));
+    EXPECT_EQ(lookup_offset(result), -(6 * 3600 + 1800));
+
+    EXPECT_TRUE(TimezoneUtils::parse_tz_offset_string("UTC", result));
+    EXPECT_EQ(lookup_offset(result), 0);
 
     // out of range or illegal format
     EXPECT_FALSE(TimezoneUtils::parse_tz_offset_string("+15:00", result));
     EXPECT_FALSE(TimezoneUtils::parse_tz_offset_string("-13:00", result));
-    EXPECT_FALSE(TimezoneUtils::parse_tz_offset_string("+9:30", result));
+    EXPECT_FALSE(TimezoneUtils::parse_tz_offset_string("+800", result));
+    EXPECT_FALSE(TimezoneUtils::parse_tz_offset_string("0800", result));
+    EXPECT_FALSE(TimezoneUtils::parse_tz_offset_string("UTC+8:75", result));
 }
 
 TEST(TimezoneUtilsTest, LoadOffsets) {
@@ -99,36 +105,45 @@ TEST(TimezoneUtilsTest, FindTimezone) {
     std::string tzname;
     cctz::time_zone result;
     const auto tp = cctz::civil_second(2011, 1, 1, 0, 0, 0);
+    const auto lookup_offset = [&](const cctz::time_zone& tz) {
+        return tz.lookup(cctz::convert(tp, tz)).offset;
+    };
 
     tzname = "Asia/Shanghai";
-    TimezoneUtils::find_cctz_time_zone(tzname, result);
-    auto cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, 8 * 3600);
+    EXPECT_TRUE(TimezoneUtils::find_cctz_time_zone(tzname, result));
+    EXPECT_EQ(lookup_offset(result), 8 * 3600);
 
     tzname = "America/Los_Angeles";
-    TimezoneUtils::find_cctz_time_zone(tzname, result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, -8 * 3600);
+    EXPECT_TRUE(TimezoneUtils::find_cctz_time_zone(tzname, result));
+    EXPECT_EQ(lookup_offset(result), -8 * 3600);
 
     tzname = "+00:30";
-    TimezoneUtils::find_cctz_time_zone(tzname, result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, 1800);
+    EXPECT_TRUE(TimezoneUtils::find_cctz_time_zone(tzname, result));
+    EXPECT_EQ(lookup_offset(result), 1800);
 
     tzname = "-00:00";
-    TimezoneUtils::find_cctz_time_zone(tzname, result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, 0);
+    EXPECT_TRUE(TimezoneUtils::find_cctz_time_zone(tzname, result));
+    EXPECT_EQ(lookup_offset(result), 0);
 
     tzname = "+14:00";
-    TimezoneUtils::find_cctz_time_zone(tzname, result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, 14 * 3600);
+    EXPECT_TRUE(TimezoneUtils::find_cctz_time_zone(tzname, result));
+    EXPECT_EQ(lookup_offset(result), 14 * 3600);
 
     tzname = "-12:00";
-    TimezoneUtils::find_cctz_time_zone(tzname, result);
-    cl = result.lookup(cctz::convert(tp, result));
-    EXPECT_EQ(cl.offset, -12 * 3600);
+    EXPECT_TRUE(TimezoneUtils::find_cctz_time_zone(tzname, result));
+    EXPECT_EQ(lookup_offset(result), -12 * 3600);
+
+    tzname = "+8:00";
+    EXPECT_TRUE(TimezoneUtils::find_cctz_time_zone(tzname, result));
+    EXPECT_EQ(lookup_offset(result), 8 * 3600);
+
+    tzname = "UTC+8";
+    EXPECT_TRUE(TimezoneUtils::find_cctz_time_zone(tzname, result));
+    EXPECT_EQ(lookup_offset(result), 8 * 3600);
+
+    tzname = "GMT-6";
+    EXPECT_TRUE(TimezoneUtils::find_cctz_time_zone(tzname, result));
+    EXPECT_EQ(lookup_offset(result), -6 * 3600);
 
     // out of range or illegal format
     tzname = "+15:00";
@@ -137,8 +152,42 @@ TEST(TimezoneUtilsTest, FindTimezone) {
     tzname = "-13:00";
     EXPECT_FALSE(TimezoneUtils::find_cctz_time_zone(tzname, result));
 
-    tzname = "+9:30";
+    tzname = "+800";
     EXPECT_FALSE(TimezoneUtils::find_cctz_time_zone(tzname, result));
 }
 
+TEST(TimezoneUtilsTest, TryGetFixedOffsetSeconds) {
+    TimezoneUtils::load_timezones_to_cache();
+
+    cctz::time_zone result;
+    int32_t offset_seconds = 0;
+
+    ASSERT_TRUE(TimezoneUtils::find_cctz_time_zone("UTC", result));
+    EXPECT_TRUE(TimezoneUtils::try_get_fixed_offset_seconds(result, &offset_seconds));
+    EXPECT_EQ(0, offset_seconds);
+
+    ASSERT_TRUE(TimezoneUtils::find_cctz_time_zone("Etc/UTC", result));
+    EXPECT_TRUE(TimezoneUtils::try_get_fixed_offset_seconds(result, &offset_seconds));
+    EXPECT_EQ(0, offset_seconds);
+
+    ASSERT_TRUE(TimezoneUtils::find_cctz_time_zone("+08:00", result));
+    EXPECT_TRUE(TimezoneUtils::try_get_fixed_offset_seconds(result, &offset_seconds));
+    EXPECT_EQ(8 * 3600, offset_seconds);
+
+    ASSERT_TRUE(TimezoneUtils::find_cctz_time_zone("Etc/GMT-8", result));
+    EXPECT_TRUE(TimezoneUtils::try_get_fixed_offset_seconds(result, &offset_seconds));
+    EXPECT_EQ(8 * 3600, offset_seconds);
+
+    ASSERT_TRUE(TimezoneUtils::find_cctz_time_zone("-06:00", result));
+    EXPECT_TRUE(TimezoneUtils::try_get_fixed_offset_seconds(result, &offset_seconds));
+    EXPECT_EQ(-6 * 3600, offset_seconds);
+
+    ASSERT_TRUE(TimezoneUtils::find_cctz_time_zone("+05:45", result));
+    EXPECT_TRUE(TimezoneUtils::try_get_fixed_offset_seconds(result, &offset_seconds));
+    EXPECT_EQ(5 * 3600 + 45 * 60, offset_seconds);
+
+    ASSERT_TRUE(TimezoneUtils::find_cctz_time_zone("Asia/Shanghai", result));
+    EXPECT_FALSE(TimezoneUtils::try_get_fixed_offset_seconds(result, &offset_seconds));
+}
+
 } // namespace doris
diff --git a/regression-test/suites/external_table_p0/hive/test_hive_date_timezone.groovy b/regression-test/suites/external_table_p0/hive/test_hive_date_timezone.groovy
index 26371b8f5c7..bc841e7d7ac 100644
--- a/regression-test/suites/external_table_p0/hive/test_hive_date_timezone.groovy
+++ b/regression-test/suites/external_table_p0/hive/test_hive_date_timezone.groovy
@@ -51,6 +51,35 @@ suite("test_hive_date_timezone", "p0,external") {
             sql """set time_zone = 'America/Mexico_City'"""
             qt_orc_date_west_tz """select date_col from orc_primitive_types_to_date order by id"""
             qt_parquet_date_west_tz """select date_col from parquet_primitive_types_to_date order by id"""
+
+            // The parquet timestamp table exercises the optimized timestamp convert path.
+            // Querying the same data under multiple timezone spellings lets this suite cover
+            // both fixed-offset normalization and named-timezone lookup behavior.
+            sql """set time_zone = 'UTC'"""
+            def parquetTimestampUtc = sql """select timestamp_col from parquet_primitive_types_to_timestamp order by id"""
+            sql """set time_zone = 'Etc/UTC'"""
+            def parquetTimestampEtcUtc = sql """select timestamp_col from parquet_primitive_types_to_timestamp order by id"""
+            sql """set time_zone = '+08:00'"""
+            def parquetTimestampFixedOffset = sql """select timestamp_col from parquet_primitive_types_to_timestamp order by id"""
+            sql """set time_zone = '+8:00'"""
+            def parquetTimestampShortOffset = sql """select timestamp_col from parquet_primitive_types_to_timestamp order by id"""
+            sql """set time_zone = 'Etc/GMT-8'"""
+            def parquetTimestampEtcGmtMinus8 = sql """select timestamp_col from parquet_primitive_types_to_timestamp order by id"""
+            sql """set time_zone = '-06:00'"""
+            def parquetTimestampFixedMexicoOffset = sql """select timestamp_col from parquet_primitive_types_to_timestamp order by id"""
+            sql """set time_zone = 'America/Mexico_City'"""
+            def parquetTimestampMexicoCity = sql """select timestamp_col from parquet_primitive_types_to_timestamp order by id"""
+
+            // Equivalent UTC spellings should stay on the same result set.
+            assertEquals(parquetTimestampUtc, parquetTimestampEtcUtc)
+            // These inputs are normalized to the same fixed offset and should match exactly.
+            assertEquals(parquetTimestampFixedOffset, parquetTimestampShortOffset)
+            // Etc/GMT-8 is a fixed-offset TZDB name. The sign is POSIX-style, so it means UTC+8.
+            assertEquals(parquetTimestampFixedOffset, parquetTimestampEtcGmtMinus8)
+            // America/Mexico_City must still read through the named-timezone path, not a constant
+            // -06:00 offset. This fixture contains a 2022 DST timestamp that makes the results differ.
+            assertEquals(parquetTimestampUtc.size(), parquetTimestampMexicoCity.size())
+            assertTrue(parquetTimestampFixedMexicoOffset != parquetTimestampMexicoCity)
         } finally {
             sql """set time_zone = default"""
             sql """switch internal"""


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org