dragosmg commented on a change in pull request #12402:
URL: https://github.com/apache/arrow/pull/12402#discussion_r837852972
##########
File path: r/tests/testthat/test-dplyr-funcs-datetime.R
##########
@@ -118,6 +118,51 @@ test_that("errors in strptime", {
)
})
+test_that("strptime returns NA when format doesn't match the data", {
+ df <- tibble(
+ str_date = c("2022-02-07", "2012/02-07", "1975/01-02", "1981/01-07")
+ )
+
+ expect_equal(
+ df %>%
+ arrow_table() %>%
+ mutate(
+ r_obj_parsed_date = strptime("03-27/2022", format = "%m-%d/%Y"),
+ r_obj_parsed_na = strptime("03-27/2022", format = "Y%-%m-%d")) %>%
+ collect(),
+ tibble(
+ str_date = c("2022-02-07", "2012/02-07", "1975/01-02", "1981/01-07"),
+ r_obj_parsed_date = as.POSIXct(rep("2022-03-27", 4)),
+ r_obj_parsed_na = as.POSIXct(rep(NA, 4))
+ ),
+ ignore_attr = "tzone"
+ )
Review comment:
Nope, `base::strptime()` and the Arrow binding return different types.
`ignore_attr` cannot help here since that covers only classes, not types.
`base::strptime()` returns a list (`POSIXlt`), while the Arrow binding returns
a `double` (`POSIXct`) vector => `compare_dplyr_binding()` would always fail.
--
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]