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

amoeba pushed a commit to branch maint-24.0.0-r
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/maint-24.0.0-r by this push:
     new 612da719aa Try patch from GH-49867
612da719aa is described below

commit 612da719aaeaa0c2b11ce4f859db6f71188c0f25
Author: Bryce Mecum <[email protected]>
AuthorDate: Sun Apr 26 20:29:18 2026 -0700

    Try patch from GH-49867
---
 r/DESCRIPTION          |  1 +
 r/R/arrow-package.R    | 20 ++++++++++++++++++++
 r/R/arrowExports.R     |  4 ++++
 r/src/arrowExports.cpp | 16 +++++++++++++---
 r/src/config.cpp       | 16 ++++++++++++++++
 5 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/r/DESCRIPTION b/r/DESCRIPTION
index 37d7df76cc..d013cb601a 100644
--- a/r/DESCRIPTION
+++ b/r/DESCRIPTION
@@ -70,6 +70,7 @@ Suggests:
     sys,
     testthat (>= 3.3.0),
     tibble,
+    tzdb,
     withr
 LinkingTo: cpp11 (>= 0.4.2)
 Collate:
diff --git a/r/R/arrow-package.R b/r/R/arrow-package.R
index 9de7afe022..0de418fc1d 100644
--- a/r/R/arrow-package.R
+++ b/r/R/arrow-package.R
@@ -153,6 +153,14 @@ s3_finalizer <- new.env(parent = emptyenv())
     # Disable multithreading on Windows
     # See https://issues.apache.org/jira/browse/ARROW-8379
     options(arrow.use_threads = FALSE)
+
+    # Use the tzdata package to configure the tzdata database on non-MSVC (i.e.
+    # MinGW) systems. This fix was put in specifically for Winbuilder (See
+    # GH-49866) but is needed for all non-MSVC systems. This code assumes the
+    # tzdata package is in Suggests.
+    if (!identical(build_info()[[2]], "MSVC")) {
+      configure_tzdb()
+    }
   }
 
   # Set interrupt handlers
@@ -169,6 +177,18 @@ s3_finalizer <- new.env(parent = emptyenv())
   invisible()
 }
 
+configure_tzdb <- function() {
+  if (requireNamespace("tzdb", quietly = TRUE)) {
+    tzdb::tzdb_initialize()
+    set_timezone_database(tzdb::tzdb_path("text"))
+  } else {
+    packageStartupMessage(
+      "The tzdb package is not installed. ",
+      "Timezones will not be available to Arrow compute functions."
+    )
+  }
+}
+
 .onAttach <- function(libname, pkgname) {
   # Just to be extra safe, let's wrap this in a try();
   # we don't want a failed startup message to prevent the package from loading
diff --git a/r/R/arrowExports.R b/r/R/arrowExports.R
index 778d242023..455e6bc8a7 100644
--- a/r/R/arrowExports.R
+++ b/r/R/arrowExports.R
@@ -552,6 +552,10 @@ runtime_info <- function() {
   .Call(`_arrow_runtime_info`)
 }
 
+set_timezone_database <- function(path) {
+  invisible(.Call(`_arrow_set_timezone_database`, path))
+}
+
 csv___WriteOptions__initialize <- function(options) {
   .Call(`_arrow_csv___WriteOptions__initialize`, options)
 }
diff --git a/r/src/arrowExports.cpp b/r/src/arrowExports.cpp
index 560466495e..1ebb81e1ed 100644
--- a/r/src/arrowExports.cpp
+++ b/r/src/arrowExports.cpp
@@ -1383,6 +1383,15 @@ BEGIN_CPP11
        return cpp11::as_sexp(runtime_info());
 END_CPP11
 }
+// config.cpp
+void set_timezone_database(cpp11::strings path);
+extern "C" SEXP _arrow_set_timezone_database(SEXP path_sexp){
+BEGIN_CPP11
+       arrow::r::Input<cpp11::strings>::type path(path_sexp);
+       set_timezone_database(path);
+       return R_NilValue;
+END_CPP11
+}
 // csv.cpp
 std::shared_ptr<arrow::csv::WriteOptions> 
csv___WriteOptions__initialize(cpp11::list options);
 extern "C" SEXP _arrow_csv___WriteOptions__initialize(SEXP options_sexp){
@@ -5835,9 +5844,10 @@ static const R_CallMethodDef CallEntries[] = {
                { "_arrow_compute__GetFunctionNames", (DL_FUNC) 
&_arrow_compute__GetFunctionNames, 0}, 
                { "_arrow_compute__Initialize", (DL_FUNC) 
&_arrow_compute__Initialize, 0}, 
                { "_arrow_RegisterScalarUDF", (DL_FUNC) 
&_arrow_RegisterScalarUDF, 2}, 
-               { "_arrow_build_info", (DL_FUNC) &_arrow_build_info, 0}, 
-               { "_arrow_runtime_info", (DL_FUNC) &_arrow_runtime_info, 0}, 
-               { "_arrow_csv___WriteOptions__initialize", (DL_FUNC) 
&_arrow_csv___WriteOptions__initialize, 1}, 
+               { "_arrow_build_info", (DL_FUNC) &_arrow_build_info, 0},
+               { "_arrow_runtime_info", (DL_FUNC) &_arrow_runtime_info, 0},
+               { "_arrow_set_timezone_database", (DL_FUNC) 
&_arrow_set_timezone_database, 1},
+               { "_arrow_csv___WriteOptions__initialize", (DL_FUNC) 
&_arrow_csv___WriteOptions__initialize, 1},
                { "_arrow_csv___ReadOptions__initialize", (DL_FUNC) 
&_arrow_csv___ReadOptions__initialize, 1}, 
                { "_arrow_csv___ParseOptions__initialize", (DL_FUNC) 
&_arrow_csv___ParseOptions__initialize, 1}, 
                { "_arrow_csv___ReadOptions__column_names", (DL_FUNC) 
&_arrow_csv___ReadOptions__column_names, 1}, 
diff --git a/r/src/config.cpp b/r/src/config.cpp
index 1855f96ac6..950e29a168 100644
--- a/r/src/config.cpp
+++ b/r/src/config.cpp
@@ -17,6 +17,8 @@
 
 #include "./arrow_types.h"
 
+#include <optional>
+
 #include <arrow/config.h>
 
 // [[arrow::export]]
@@ -31,3 +33,17 @@ std::vector<std::string> runtime_info() {
   auto info = arrow::GetRuntimeInfo();
   return {info.simd_level, info.detected_simd_level};
 }
+
+// [[arrow::export]]
+void set_timezone_database(cpp11::strings path) {
+  auto paths = cpp11::as_cpp<std::vector<std::string>>(path);
+  if (path.size() != 1) {
+    cpp11::stop("Must provide a single path to the timezone database.");
+  }
+
+  ARROW_SUPPRESS_DEPRECATION_WARNING
+  arrow::GlobalOptions options;
+  options.timezone_db_path = std::make_optional(paths[0]);
+  ARROW_UNSUPPRESS_DEPRECATION_WARNING
+  arrow::StopIfNotOk(arrow::Initialize(options));
+}

Reply via email to