djnavarro commented on a change in pull request #12154: URL: https://github.com/apache/arrow/pull/12154#discussion_r785513228
########## File path: r/tests/testthat/test-dplyr-funcs-datetime.R ########## @@ -616,3 +616,292 @@ test_that("extract yday from date", { test_df ) }) + +test_that("round/floor/ceiling on datetime (to nearest second)", { + compare_dplyr_binding( + .input %>% + mutate( + out_1 = round_date(datetime), + out_2 = floor_date(datetime), + out_3 = ceiling_date(datetime), + ) %>% + collect(), + test_df + ) +}) + +test_that("period unit abbreviation", { + compare_dplyr_binding( + .input %>% + mutate( + out_1 = round_date(datetime, "minute"), + out_2 = round_date(datetime, "minutes"), + out_3 = round_date(datetime, "mins"), + ) %>% + collect(), + test_df + ) +}) + +test_that("period unit extracts integer multiples", { + compare_dplyr_binding( + .input %>% + mutate( + out_1 = round_date(datetime, "1 minute"), + out_2 = round_date(datetime, "2 minutes"), + out_3 = round_date(datetime, "10 minutes") + ) %>% + collect(), + test_df + ) +}) + +# lubridate errors when 60 sec/60 min/24 hour thresholds exceeded. +# this test checks that arrow does too. +test_that("period unit maxima are enforced", { + + expect_error(suppressWarnings( # <- hack + test_df %>% + arrow_table() %>% + mutate(out = round_date(datetime, "61 seconds")) %>% + collect() + )) Review comment: Nice! I hadn't realised `call_binding()` existed 🤦🏻♀️ 😁 -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org