-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-14942: [R] Bindings for lubridate's dpicoseconds, dnanoseconds, desconds, dmilliseconds, dmicroseconds #12855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
df230a5
1dc35c6
0ca4d80
b7de259
5bd6a5e
d139be7
f0678b1
26a30c5
aa3d54f
10ce36b
9aca24d
3991f5c
9a6c5f7
115c6c4
eda6b8c
13e11a7
23ca370
bef9aa9
17b7fa4
55ab2c7
6e0c9bb
00a5eef
cfae99c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1258,7 +1258,12 @@ test_that("`decimal_date()` and `date_decimal()`", { | |
|
|
||
| test_that("dminutes, dhours, ddays, dweeks, dmonths, dyears", { | ||
| example_d <- tibble(x = c(1:10, NA)) | ||
| date_to_add <- ymd("2009-08-03", tz = "America/Chicago") | ||
| date_to_add <- ymd("2009-08-03", tz = "Pacific/Marquesas") | ||
|
|
||
| # When comparing results we use ignore_attr = TRUE because of the diff in: | ||
| # attribute 'package' (absent vs. 'lubridate') | ||
| # class (difftime vs Duration) | ||
| # attribute 'units' (character vector ('secs') vs. absent) | ||
|
|
||
| compare_dplyr_binding( | ||
| .input %>% | ||
|
|
@@ -1303,6 +1308,79 @@ test_that("dminutes, dhours, ddays, dweeks, dmonths, dyears", { | |
| tibble(), | ||
| ignore_attr = TRUE | ||
| ) | ||
|
|
||
| # double -> duration not supported in Arrow. | ||
| # Error is generated in the C++ code | ||
| expect_error( | ||
| test_df %>% | ||
| arrow_table() %>% | ||
| mutate(r_obj_dminutes = dminutes(1.12345)) %>% | ||
| collect() | ||
| ) | ||
|
Comment on lines
+1312
to
+1319
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for this comment about why we are |
||
| }) | ||
|
|
||
| test_that("dseconds, dmilliseconds, dmicroseconds, dnanoseconds, dpicoseconds", { | ||
| example_d <- tibble(x = c(1:10, NA)) | ||
|
||
| date_to_add <- ymd("2009-08-03", tz = "Pacific/Marquesas") | ||
|
|
||
| # When comparing results we use ignore_attr = TRUE because of the diff in: | ||
| # attribute 'package' (absent vs. 'lubridate') | ||
| # class (difftime vs Duration) | ||
| # attribute 'units' (character vector ('secs') vs. absent) | ||
|
|
||
| compare_dplyr_binding( | ||
| .input %>% | ||
| mutate( | ||
| dseconds = dseconds(x), | ||
| dmilliseconds = dmilliseconds(x), | ||
| dmicroseconds = dmicroseconds(x), | ||
| dnanoseconds = dnanoseconds(x), | ||
| ) %>% | ||
| collect(), | ||
| example_d, | ||
| ignore_attr = TRUE | ||
| ) | ||
|
|
||
| compare_dplyr_binding( | ||
| .input %>% | ||
| mutate( | ||
| dseconds = dseconds(x), | ||
| dmicroseconds = dmicroseconds(x), | ||
| new_date_1 = date_to_add + dseconds, | ||
| new_date_2 = date_to_add + dseconds - dmicroseconds, | ||
| new_duration = dseconds - dmicroseconds | ||
| ) %>% | ||
| collect(), | ||
| example_d, | ||
| ignore_attr = TRUE | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't see this in the PR (though might have missed something), what
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add a comment, you can wait with merging. But I have to remember, if I am honest =) Will do it tomorrow morning and add the comment then. Thank you for the review!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are using |
||
| ) | ||
|
|
||
| compare_dplyr_binding( | ||
| .input %>% | ||
| mutate( | ||
| r_obj_dseconds = dseconds(1), | ||
| r_obj_dmilliseconds = dmilliseconds(2), | ||
| r_obj_dmicroseconds = dmicroseconds(3), | ||
| r_obj_dnanoseconds = dnanoseconds(4) | ||
| ) %>% | ||
| collect(), | ||
| tibble(), | ||
| ignore_attr = TRUE | ||
| ) | ||
|
|
||
| expect_error( | ||
| call_binding("dpicoseconds"), | ||
| "Duration in picoseconds not supported in Arrow" | ||
| ) | ||
|
|
||
| # double -> duration not supported in Arrow. | ||
| # Error is generated in the C++ code | ||
| expect_error( | ||
| test_df %>% | ||
| arrow_table() %>% | ||
| mutate(r_obj_dseconds = dseconds(1.12345)) %>% | ||
| collect() | ||
| ) | ||
| }) | ||
|
|
||
| test_that("make_difftime()", { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This is actually even shorter than I though it would be!