Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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 r/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Suggests:
sys,
testthat (>= 3.3.0),
tibble,
tzdb,
withr
LinkingTo: cpp11 (>= 0.4.2)
Collate:
Expand Down
20 changes: 20 additions & 0 deletions r/R/arrow-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we wrap this in a try/catch and warn if this goes wrong? It would effectively be the same as if they didn't have it, so it might be nice to not block folks from using arrow at all.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a good idea, I'll add it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in deb3bc6. I did it as a packageStartupMessage which felt right.

} else {
packageStartupMessage(
"The tzdb package is not installed. ",
"Timezones will not be available to Arrow compute functions."
Comment thread
amoeba marked this conversation as resolved.
Outdated
)
}
}

.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
Expand Down
4 changes: 4 additions & 0 deletions r/R/arrowExports.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions r/src/arrowExports.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions r/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include "./arrow_types.h"

#include <optional>

#include <arrow/config.h>

// [[arrow::export]]
Expand All @@ -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));
}
Loading