From 345bcc1fc652a0c8f8b1eead2f6fb6a68a74947d Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Tue, 21 May 2024 23:10:42 +1100 Subject: [PATCH] teach CheckTimeZoneDatabaseAvailability how to inspect conda environments --- cpp/src/arrow/adapters/orc/adapter.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cpp/src/arrow/adapters/orc/adapter.cc b/cpp/src/arrow/adapters/orc/adapter.cc index 98784450b3cce..81affbe50d5f5 100644 --- a/cpp/src/arrow/adapters/orc/adapter.cc +++ b/cpp/src/arrow/adapters/orc/adapter.cc @@ -189,15 +189,20 @@ liborc::RowReaderOptions DefaultRowReaderOptions() { #ifdef ARROW_ORC_NEED_TIME_ZONE_DATABASE_CHECK // Proactively check timezone database availability for ORC versions older than 2.0.0 Status CheckTimeZoneDatabaseAvailability() { - auto tz_dir = std::getenv("TZDIR"); - bool is_tzdb_avaiable = tz_dir != nullptr + // orc >=2.0.1 will look for tzdb in $CONDA_PREFIX/share/zoneinfo, + // which is provided by the package `tzdata` (if installed) + auto conda_prefix = std::getenv("CONDA_PREFIX"); + auto tz_dir = conda_prefix != nullptr + ? std::string(conda_prefix) + "/share/zoneinfo" + : std::string(std::getenv("TZDIR")); + bool is_tzdb_available = tz_dir != nullptr ? std::filesystem::exists(tz_dir) : std::filesystem::exists("/usr/share/zoneinfo"); - if (!is_tzdb_avaiable) { + if (!is_tzdb_available) { return Status::Invalid( "IANA time zone database is unavailable but required by ORC." " Please install it to /usr/share/zoneinfo or set TZDIR env to the installed" - " directory"); + " directory. If you are using conda, simply install the package `tzdata`."); } return Status::OK(); }