Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.3k
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
df230a51dc35c60ca4d80b7de2595bd6a5ed139be7f0678b126a30c5aa3d54f10ce36b9aca24d3991f5c9a6c5f7115c6c4eda6b8c13e11a723ca370bef9aa917b7fa455ab2c76e0c9bb00a5eefcfae99cFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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)) | ||
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. Should we also test what happens when we pass floats here too? Seems to work, so we should ensure we can do that (or error helpfully if we can't for some reason)
| ||
| 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 MemberAuthor 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! MemberAuthor 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!