jonkeane commented on code in PR #12855:
URL: https://github.com/apache/arrow/pull/12855#discussion_r851296829
##########
r/tests/testthat/test-dplyr-funcs-datetime.R:
##########
@@ -1304,3 +1304,53 @@ test_that("dminutes, dhours, ddays, dweeks, dmonths,
dyears", {
ignore_attr = TRUE
)
})
+
+test_that("dseconds, dmilliseconds, dmicroseconds, dnanoseconds,
dpicoseconds", {
+ example_d <- tibble(x = c(1:10, NA))
+ date_to_add <- ymd("2009-08-03", tz = "America/Chicago")
Review Comment:
```suggestion
date_to_add <- ymd("2009-08-03", tz = "Pacific/Marquesas")
```
If we don't need a specific feature of Chicago's timezone here, we should
use our default "unusual" timezone of "Pacific/Marquesas" so that we have a low
probability of this being a developer's timezone
##########
r/tests/testthat/test-dplyr-funcs-datetime.R:
##########
@@ -1304,3 +1304,53 @@ test_that("dminutes, dhours, ddays, dweeks, dmonths,
dyears", {
ignore_attr = TRUE
)
})
+
+test_that("dseconds, dmilliseconds, dmicroseconds, dnanoseconds,
dpicoseconds", {
+ example_d <- tibble(x = c(1:10, NA))
Review Comment:
Should we also test what happens when we pass floats here too?
```
> lubridate::dseconds(1.5)
[1] "1.5s"
```
Seems to work, so we should ensure we can do that (or error helpfully if we
can't for some reason)
##########
r/R/dplyr-funcs-datetime.R:
##########
@@ -376,6 +376,21 @@ register_bindings_duration_helpers <- function() {
register_binding("dyears", function(x = 1) {
make_duration(x * 31557600, "s")
})
+ register_binding("dseconds", function(x = 1) {
+ make_duration(x, "s")
+ })
+ register_binding("dmilliseconds", function(x = 1) {
+ make_duration(x, "ms")
+ })
+ register_binding("dmicroseconds", function(x = 1) {
+ make_duration(x, "us")
+ })
+ register_binding("dnanoseconds", function(x = 1) {
+ make_duration(x, "ns")
+ })
+ register_binding("dpicoseconds", function(x = 1) {
+ abort("Duration in picoseconds not supported in Arrow.")
+ })
Review Comment:
I think we should keep this as is written out like this, but this is right
on the border where we might consider doing the mapping between function names
and durations programmatically call `register_binding()`.
--
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]