You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by np...@apache.org on 2022/05/09 19:11:20 UTC
[arrow] branch master updated: MINOR: [R] Move tzdb loading out of .onLoad() to avoid a check NOTE
This is an automated email from the ASF dual-hosted git repository.
npr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new b264dca5a0 MINOR: [R] Move tzdb loading out of .onLoad() to avoid a check NOTE
b264dca5a0 is described below
commit b264dca5a00cb889e1caf24f41a5f018c96cec4d
Author: Neal Richardson <ne...@gmail.com>
AuthorDate: Mon May 9 15:11:12 2022 -0400
MINOR: [R] Move tzdb loading out of .onLoad() to avoid a check NOTE
`R CMD check` now raises a NOTE after my previous fix (f49fbda3dffeaead7d192ec64bfd2a7cfc4172a3):
```
* checking R code for possible problems ... NOTE
File ‘arrow/R/arrow-package.R’:
.onLoad calls:
packageStartupMessage("The tzdb package is not installed. Timezones will not be available.")
See section ‘Good practice’ in '?.onAttach'.
```
Interestingly, the docs they point to say to use `packageStartupMessage()` like we are doing here. In any case, if we move it to a function that `.onLoad()` calls rather than having it directly in .onLoad, `check` doesn't find it 🤷
Closes #13104 from nealrichardson/tzdb-msg-2
Authored-by: Neal Richardson <ne...@gmail.com>
Signed-off-by: Neal Richardson <ne...@gmail.com>
---
r/R/arrow-package.R | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/r/R/arrow-package.R b/r/R/arrow-package.R
index 1b2e7691ef..1f57ef3f14 100644
--- a/r/R/arrow-package.R
+++ b/r/R/arrow-package.R
@@ -72,12 +72,7 @@
options(arrow.use_threads = FALSE)
# Try to set timezone database
- 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.")
- }
+ configure_tzdb()
}
if (arrow_available()) {
@@ -88,6 +83,20 @@
invisible()
}
+configure_tzdb <- function() {
+ # This is needed on Windows to support timezone-aware calculations
+ if (requireNamespace("tzdb", quietly = TRUE)) {
+ tzdb::tzdb_initialize()
+ set_timezone_database(tzdb::tzdb_path("text"))
+ } else {
+ msg <- paste(
+ "The tzdb package is not installed.",
+ "Timezones will not be available to Arrow compute functions."
+ )
+ packageStartupMessage(msg)
+ }
+}
+
.onAttach <- function(libname, pkgname) {
if (!arrow_available()) {
msg <- paste(