Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore](be) Add default timezone files #25097

Merged
merged 4 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
3 changes: 3 additions & 0 deletions be/src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,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
Expand Down
3 changes: 3 additions & 0 deletions be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,9 @@ DECLARE_Bool(enable_cpu_hard_limit);
// 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);
Expand Down
15 changes: 10 additions & 5 deletions be/src/util/timezone_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <shared_mutex>
#include <string>

#include "common/config.h"
#include "common/exception.h"
#include "common/logging.h"

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion be/test/vec/function/function_time_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ clean_be() {

rm -rf "${CMAKE_BUILD_DIR}"
rm -rf "${DORIS_HOME}/be/output"
rm -rf "${DORIS_HOME}/zoneinfo"
popd
}

Expand Down Expand Up @@ -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/"
Expand Down
Binary file added resource/zoneinfo.tar.gz
Binary file not shown.
Loading