jonkeane commented on code in PR #13190: URL: https://github.com/apache/arrow/pull/13190#discussion_r890584364
########## r/tests/testthat/test-dplyr-funcs-datetime.R: ########## @@ -50,49 +50,72 @@ test_df <- tibble::tibble( test_that("strptime", { t_string <- tibble(x = c("2018-10-07 19:04:05", NA)) t_stamp <- tibble(x = c(lubridate::ymd_hms("2018-10-07 19:04:05"), NA)) + t_stamp_with_pm_tz <- tibble( + x = c(lubridate::ymd_hms("2018-10-07 19:04:05", tz = "Pacific/Marquesas"), NA) + ) + + # base::strptime returns a POSIXlt (a list) => we cannot use compare_dplyr_binding + # => we use expect_equal + withr::with_timezone("Pacific/Marquesas", { + expect_equal( + t_string %>% + record_batch() %>% + mutate( + x = strptime(x, format = "%Y-%m-%d %H:%M:%S") + ) %>% + collect(), + t_stamp_with_pm_tz + ) + }) + + expect_equal( + t_string %>% + arrow_table() %>% + mutate( + x = strptime(x, format = "%Y-%m-%d %H:%M:%S", tz = "Pacific/Marquesas") + ) %>% + collect(), + t_stamp_with_pm_tz + ) expect_equal( t_string %>% Table$create() %>% mutate( - x = strptime(x) + x = strptime(x, tz = "UTC") ) %>% collect(), - t_stamp, - ignore_attr = "tzone" + t_stamp ) expect_equal( t_string %>% Table$create() %>% mutate( - x = strptime(x, format = "%Y-%m-%d %H:%M:%S") + x = strptime(x, format = "%Y-%m-%d %H:%M:%S", tz = "UTC") ) %>% collect(), - t_stamp, - ignore_attr = "tzone" + t_stamp ) expect_equal( t_string %>% Table$create() %>% mutate( - x = strptime(x, format = "%Y-%m-%d %H:%M:%S", unit = "ns") + x = strptime(x, format = "%Y-%m-%d %H:%M:%S", unit = "ns", tz = "UTC") ) %>% collect(), - t_stamp, - ignore_attr = "tzone" + t_stamp ) expect_equal( t_string %>% Table$create() %>% mutate( - x = strptime(x, format = "%Y-%m-%d %H:%M:%S", unit = "s") + x = strptime(x, format = "%Y-%m-%d %H:%M:%S", unit = "s", tz = "UTC") Review Comment: Nope, that's good. It might be worth adding a comment explaining the significance of that (along with some of the other tests around it). -- 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