diff --git a/.gitignore b/.gitignore index 10fc199fc3..84fc3064e6 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 780eeca097..1634ea575f 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 caca2255cb..e17e4b5f67 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 a90f30820a..d3f6ff9af4 100644 --- a/be/src/util/timezone_utils.cpp +++ b/be/src/util/timezone_utils.cpp @@ -36,6 +36,7 @@ #include #include +#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 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 56f49ec6c9..cf64fd9e55 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 4f6a58ec71..9c8f415d77 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 0000000000..db010ccce9 Binary files /dev/null and b/resource/zoneinfo.tar.gz differ