jonkeane commented on a change in pull request #12353:
URL: https://github.com/apache/arrow/pull/12353#discussion_r802008905
##########
File path: r/tests/testthat/test-dplyr-funcs-datetime.R
##########
@@ -711,3 +711,35 @@ test_that("am/pm mirror lubridate", {
)
})
+
+test_that("date/time parsing / ymd() and `-` separator", {
+ test_dates <- tibble::tibble(
+ string_ymd = c(
+ "2021-09-10", "2021/09/10", "2021.09.10", "2021,09,10", "2021:09:10",
+ "20210910", "2021 Sep 10", "2021 September 10", "21-09-10", "21/09/10",
+ "21.09.10", "21,09,10", "21:09:10", "210910", "21 Sep 10",
+ "21 September 10", NA
+ ),
+ string_dmy = c(
+ "10-09-2021", "10/09/2021", "10.09.2021", "10,09,2021", "10:09:2021",
+ "10092021", "10 Sep 2021", "10 September 2021", "10-09-21", "10/09/21",
+ "10.09.21", "10,09,21", "10:09:21", "100921", "10 Sep 21",
+ "10 September 21", NA
+ ),
+ string_mdy = c(
+ "09-10-2021", "09/10/2021", "09.10.2021", "09,10,2021", "09:10:2021",
+ "09102021", "Sep 10 2021", "September 10 2021", "09-10-21", "09/10/21",
+ "09.10.21", "09,10,21", "09:10:21", "091021", "Sep 10 21",
+ "September 10 21", NA
+ ),
+ date = c(rep(as.Date("2021-09-10"), 16), NA),
+ date_midnight = c(rep(as.POSIXct("2021-09-10 00:00:00", tz = "UTC"), 16),
NA)
+ )
+
+ compare_dplyr_binding(
+ .input %>%
+ mutate(x = ymd(string_ymd)) %>%
+ collect(),
+ test_dates
+ )
Review comment:
We should also have a check that if the format fails, we get `NA`s out —
so long as that's possible)
It looks like right now, it throws an error for the whole conversion:
https://github.com/apache/arrow/runs/5094263843?check_suite_focus=true#step:6:22119
--
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]