-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-16439: [R] Implement binding for lubridate::fast_strptime
#13174
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
652a332
af4f2e1
989aafb
6423054
a238766
513e359
d713a21
346c248
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 |
|---|---|---|
|
|
@@ -1812,3 +1812,133 @@ test_that("ym, my & yq parsers", { | |
| test_df | ||
| ) | ||
| }) | ||
|
|
||
| test_that("lubridate's fast_strptime", { | ||
|
|
||
| compare_dplyr_binding( | ||
| .input %>% | ||
| mutate( | ||
| y = | ||
| fast_strptime( | ||
| x, | ||
| format = "%Y-%m-%d %H:%M:%S", | ||
| lt = FALSE | ||
| ) | ||
| ) %>% | ||
| collect(), | ||
| tibble( | ||
| x = c("2018-10-07 19:04:05", "2022-05-17 21:23:45", NA) | ||
| )#, | ||
| # arrow does not preserve the `tzone` attribute | ||
| # test ignore_attr = TRUE | ||
| ) | ||
|
|
||
| # R object | ||
| compare_dplyr_binding( | ||
| .input %>% | ||
| mutate( | ||
| y = | ||
| fast_strptime( | ||
| "68-10-07 19:04:05", | ||
| format = "%y-%m-%d %H:%M:%S", | ||
| lt = FALSE | ||
| ) | ||
| ) %>% | ||
| collect(), | ||
| tibble( | ||
| x = c("2018-10-07 19:04:05", NA) | ||
| )#, | ||
| # test ignore_attr = TRUE | ||
| ) | ||
|
|
||
| compare_dplyr_binding( | ||
| .input %>% | ||
| mutate( | ||
| date_multi_formats = | ||
| fast_strptime( | ||
| x, | ||
| format = c("%Y-%m-%d %H:%M:%S", "%m-%d-%Y %H:%M:%S"), | ||
| lt = FALSE | ||
| ) | ||
| ) %>% | ||
| collect(), | ||
| tibble( | ||
| x = c("2018-10-07 19:04:05", "10-07-1968 19:04:05") | ||
| ) | ||
| ) | ||
|
|
||
| compare_dplyr_binding( | ||
| .input %>% | ||
| mutate( | ||
| dttm_with_tz = fast_strptime( | ||
| dttm_as_string, | ||
| format = "%Y-%m-%d %H:%M:%S", | ||
| tz = "Pacific/Marquesas", | ||
| lt = FALSE | ||
| ) | ||
| ) %>% | ||
| collect(), | ||
| tibble( | ||
| dttm_as_string = | ||
| c("2018-10-07 19:04:05", "1969-10-07 19:04:05", NA) | ||
| ) | ||
| ) | ||
|
|
||
| # fast_strptime()'s `cutoff_2000` argument is not supported, but its value is | ||
| # implicitly set to 68L both in lubridate and in Arrow | ||
| compare_dplyr_binding( | ||
| .input %>% | ||
| mutate( | ||
| date_short_year = | ||
| fast_strptime( | ||
| x, | ||
| format = "%y-%m-%d %H:%M:%S", | ||
| lt = FALSE | ||
| ) | ||
| ) %>% | ||
| collect(), | ||
| tibble( | ||
| x = | ||
| c("68-10-07 19:04:05", "69-10-07 19:04:05", NA) | ||
| )#, | ||
| # arrow does not preserve the `tzone` attribute | ||
| # test ignore_attr = TRUE | ||
|
Comment on lines
+1903
to
+1905
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. We should remove these commented lines, yeah?
Contributor
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 yes, sorry. Forgot about those. Do I open a minor PR?
Contributor
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. Or should I just do it in one of the other PR I have going?
Contributor
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. @jonkeane I removed the tests in dragosmg@bde85ce |
||
| ) | ||
|
|
||
| # the arrow binding errors for a value different from 68L for `cutoff_2000` | ||
| compare_dplyr_binding( | ||
| .input %>% | ||
| mutate( | ||
| date_short_year = | ||
| fast_strptime( | ||
| x, | ||
| format = "%y-%m-%d %H:%M:%S", | ||
| lt = FALSE, | ||
| cutoff_2000 = 69L | ||
| ) | ||
| ) %>% | ||
| collect(), | ||
| tibble( | ||
| x = c("68-10-07 19:04:05", "69-10-07 19:04:05", NA) | ||
| ), | ||
| warning = TRUE | ||
dragosmg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| # compare_dplyr_binding would not work here since lt = TRUE returns a list | ||
| # and it also errors in regular dplyr pipelines | ||
| expect_warning( | ||
| tibble( | ||
| x = c("68-10-07 19:04:05", "69-10-07 19:04:05", NA) | ||
| ) %>% | ||
| arrow_table() %>% | ||
| mutate( | ||
| date_short_year = | ||
| fast_strptime( | ||
| x, | ||
| format = "%y-%m-%d %H:%M:%S", | ||
| lt = TRUE | ||
| ) | ||
| ) %>% | ||
| collect() | ||
| ) | ||
| }) | ||
Uh oh!
There was an error while loading. Please reload this page.