wgtmac commented on code in PR #40697:
URL: https://github.com/apache/arrow/pull/40697#discussion_r1538489230


##########
cpp/src/arrow/adapters/orc/adapter.cc:
##########
@@ -183,8 +184,40 @@ liborc::RowReaderOptions default_row_reader_options() {
   return options;
 }
 
+// Proactively check timezone database availability for ORC versions older 
than 2.0.0
+Status check_timezone_database_availability() {
+  if (OrcVersion::Get().value_or(OrcVersion{0, 0, 0}).major >= 2) {
+    return Status::OK();
+  }
+  auto tz_dir = std::getenv("TZDIR");
+  bool is_tzdb_avaiable = tz_dir != nullptr
+                              ? std::filesystem::exists(tz_dir)
+                              : std::filesystem::exists("/usr/share/zoneinfo");
+  if (!is_tzdb_avaiable) {
+    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");
+  }
+  return Status::OK();
+}
+
 }  // namespace
 
+std::optional<OrcVersion> OrcVersion::Get() {
+  std::vector<int> versions;
+  std::stringstream ss{ORC_VERSION};
+  while (ss.good()) {
+    std::string str;
+    std::getline(ss, str, '.');
+    versions.emplace_back(std::stoi(str));
+  }
+  if (versions.size() != 3) {

Review Comment:
   Make sense! It may also be `2.1.0-SNAPSHOT` or whatever custom patched 
version. Let me change it to only care about major and minor version instead.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to