dragosmg commented on a change in pull request #12429:
URL: https://github.com/apache/arrow/pull/12429#discussion_r808184060
##########
File path: r/tests/testthat/test-dplyr-funcs-datetime.R
##########
@@ -711,3 +711,48 @@ test_that("am/pm mirror lubridate", {
)
})
+
+test_that("semester works with temporal types", {
+ test_df <- tibble(
+ month_as_int = c(1:12, NA),
+ month_as_char_pad = ifelse(month_as_int < 10, paste0("0", month_as_int),
month_as_int),
+ dates = as.Date(paste0("2021-", month_as_char_pad, "-15"))
+ )
+
+ # test extraction from dates
+ compare_dplyr_binding(
+ .input %>%
+ mutate(sem_wo_year = semester(dates),
+ sem_w_year = semester(dates, with_year = TRUE)) %>%
+ collect(),
+ test_df
+ )
+})
+
+test_that("semester errors with integers and characters", {
+ test_df <- tibble(
+ month_as_int = c(1:12, NA),
+ month_as_char_pad = ifelse(month_as_int < 10, paste0("0", month_as_int),
month_as_int),
+ dates = as.Date(paste0("2021-", month_as_char_pad, "-15"))
+ )
+
+ # extraction from integers should error as we currently do not support
setting
+ # month components with month, but this is supported by `lubridate::month()`
+ # this should no longer fail once
https://issues.apache.org/jira/browse/ARROW-15701
+ # is addressed
Review comment:
Done
--
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]