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

gabriellee 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 9a675fcdfcf [chore](be) Add default timezone files (#25097)
9a675fcdfcf is described below

commit 9a675fcdfcf57d018d0d57bad0d9ddf82278090a
Author: zclllyybb <[email protected]>
AuthorDate: Fri Oct 20 13:12:24 2023 +0800

    [chore](be) Add default timezone files (#25097)
---
 .gitignore                                  |   1 +
 be/src/common/config.cpp                    |   3 +++
 be/src/common/config.h                      |   3 +++
 be/src/util/timezone_utils.cpp              |  15 ++++++++++-----
 be/test/vec/function/function_time_test.cpp |   1 -
 build.sh                                    |   7 +++++++
 resource/zoneinfo.tar.gz                    | Bin 0 -> 671860 bytes
 7 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index 10fc199fc31..84fc3064e68 100644
--- a/.gitignore
+++ b/.gitignore
@@ -97,6 +97,7 @@ be/tags
 be/test/olap/test_data/tablet_meta_test.hdr
 be/.devcontainer/
 be/src/apache-orc/
+zoneinfo/
 
 ## tools
 tools/ssb-tools/ssb-data/
diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp
index 780eeca097c..1634ea575f7 100644
--- a/be/src/common/config.cpp
+++ b/be/src/common/config.cpp
@@ -1114,6 +1114,9 @@ DEFINE_Bool(enable_cpu_hard_limit, "false");
 
 DEFINE_Bool(ignore_always_true_predicate_for_segment, "true");
 
+// Dir of default timezone files
+DEFINE_String(default_tzfiles_path, "${DORIS_HOME}/zoneinfo");
+
 // clang-format off
 #ifdef BE_TEST
 // test s3
diff --git a/be/src/common/config.h b/be/src/common/config.h
index caca2255cb6..e17e4b5f670 100644
--- a/be/src/common/config.h
+++ b/be/src/common/config.h
@@ -1184,6 +1184,9 @@ DECLARE_Bool(enable_flush_file_cache_async);
 // Remove predicate that is always true for a segment.
 DECLARE_Bool(ignore_always_true_predicate_for_segment);
 
+// Dir of default timezone files
+DECLARE_String(default_tzfiles_path);
+
 #ifdef BE_TEST
 // test s3
 DECLARE_String(test_s3_resource);
diff --git a/be/src/util/timezone_utils.cpp b/be/src/util/timezone_utils.cpp
index a90f30820a3..d3f6ff9af4c 100644
--- a/be/src/util/timezone_utils.cpp
+++ b/be/src/util/timezone_utils.cpp
@@ -36,6 +36,7 @@
 #include <shared_mutex>
 #include <string>
 
+#include "common/config.h"
 #include "common/exception.h"
 #include "common/logging.h"
 
@@ -77,8 +78,10 @@ void TimezoneUtils::load_timezone_names() {
     path += '/';
 
     if (!std::filesystem::exists(path)) {
-        LOG_WARNING("Cannot find system tzfile. Abandon to preload timezone 
name cache.");
-        return;
+        LOG_WARNING("Cannot find system tzfile. Use default instead.");
+        path = config::default_tzfiles_path + '/';
+        CHECK(std::filesystem::exists(path))
+                << "Can't find system tzfiles or default tzfiles neither.";
     }
 
     auto path_prefix_len = path.size();
@@ -236,10 +239,12 @@ void TimezoneUtils::load_timezones_to_cache() {
     base_str += tzdir;
     base_str += '/';
 
-    const auto root_path = std::filesystem::path {base_str};
+    auto root_path = std::filesystem::path {base_str};
     if (!std::filesystem::exists(root_path)) {
-        LOG_WARNING("Cannot find system tzfile. Abandon to preload timezone 
cache.");
-        return;
+        LOG_WARNING("Cannot find system tzfile. Use default instead.");
+        root_path = config::default_tzfiles_path + '/';
+        CHECK(std::filesystem::exists(root_path))
+                << "Can't find system tzfiles or default tzfiles neither.";
     }
 
     std::set<std::string> ignore_paths = {"posix", "right"}; // duplications
diff --git a/be/test/vec/function/function_time_test.cpp 
b/be/test/vec/function/function_time_test.cpp
index 56f49ec6c9a..cf64fd9e55a 100644
--- a/be/test/vec/function/function_time_test.cpp
+++ b/be/test/vec/function/function_time_test.cpp
@@ -202,7 +202,6 @@ TEST(VTimestampFunctionsTest, timediff_test) {
 }
 
 TEST(VTimestampFunctionsTest, convert_tz_test) {
-    GTEST_SKIP() << "Skip temporarily. need fix";
     std::string func_name = "convert_tz";
 
     TimezoneUtils::clear_timezone_caches();
diff --git a/build.sh b/build.sh
index 4f6a58ec718..9c8f415d773 100755
--- a/build.sh
+++ b/build.sh
@@ -95,6 +95,7 @@ clean_be() {
 
     rm -rf "${CMAKE_BUILD_DIR}"
     rm -rf "${DORIS_HOME}/be/output"
+    rm -rf "${DORIS_HOME}/zoneinfo"
     popd
 }
 
@@ -634,6 +635,12 @@ if [[ "${OUTPUT_BE_BINARY}" -eq 1 ]]; then
     cp -r -p "${DORIS_HOME}/be/output/bin"/* "${DORIS_OUTPUT}/be/bin"/
     cp -r -p "${DORIS_HOME}/be/output/conf"/* "${DORIS_OUTPUT}/be/conf"/
     cp -r -p "${DORIS_HOME}/be/output/dict" "${DORIS_OUTPUT}/be/"
+    if [[ ! -r "${DORIS_HOME}/zoneinfo/Africa/Abidjan" ]]; then
+        rm -rf "${DORIS_HOME}/zoneinfo"
+        echo "Generating zoneinfo files"
+        tar -xzf "${DORIS_HOME}/resource/zoneinfo.tar.gz" -C "${DORIS_HOME}"/
+    fi
+    cp -r -p "${DORIS_HOME}/zoneinfo" "${DORIS_OUTPUT}/be/"
 
     if [[ -d "${DORIS_THIRDPARTY}/installed/lib/hadoop_hdfs/" ]]; then
         cp -r -p "${DORIS_THIRDPARTY}/installed/lib/hadoop_hdfs/" 
"${DORIS_OUTPUT}/be/lib/"
diff --git a/resource/zoneinfo.tar.gz b/resource/zoneinfo.tar.gz
new file mode 100644
index 00000000000..db010ccce99
Binary files /dev/null and b/resource/zoneinfo.tar.gz differ


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

Reply via email to