paleolimbot commented on code in PR #13506:
URL: https://github.com/apache/arrow/pull/13506#discussion_r927583175
##########
r/tests/testthat/test-dplyr-funcs-datetime.R:
##########
@@ -150,6 +150,30 @@ test_that("strptime", {
as.POSIXct(tstamp),
ignore_attr = "tzone"
)
+
+ tz <- "Pacific/Marquesas"
+ times <- seq(as.POSIXct("1999-02-07", tz = tz), as.POSIXct("2000-01-01", tz
= tz), by = "hour")
+ times <- c(as.POSIXct("1999-12-31T12:34:56.01", tz = "UTC"))
Review Comment:
Did you mean to keep this second line in? I'm unclear if you meant to
actually test the first line (because it's overwritten here).
##########
r/tests/testthat/test-dplyr-funcs-datetime.R:
##########
@@ -150,6 +150,30 @@ test_that("strptime", {
as.POSIXct(tstamp),
ignore_attr = "tzone"
)
+
+ tz <- "Pacific/Marquesas"
+ times <- seq(as.POSIXct("1999-02-07", tz = tz), as.POSIXct("2000-01-01", tz
= tz), by = "hour")
+ times <- c(as.POSIXct("1999-12-31T12:34:56.01", tz = "UTC"))
+
+ # The following formats are currently not supported by strptime: %q %Op
+ formats <- c("%a", "%A", "%b", "%B", "%d", "%H", "%j", "%m", "%Om", "%T",
"%OS", "%I%p",
+ "%S", "%q", "%M", "%p", "%U", "%w", "%W", "%y", "%Y", "%r",
"%R", "%T%z")
Review Comment:
```suggestion
formats <- c(
"%a", "%A", "%b", "%B", "%d", "%H", "%j", "%m", "%Om", "%T", "%OS",
"%I%p",
"%S", "%q", "%M", "%p", "%U", "%w", "%W", "%y", "%Y", "%r", "%R", "%T%z"
)
```
##########
r/tests/testthat/test-dplyr-funcs-datetime.R:
##########
@@ -150,6 +150,30 @@ test_that("strptime", {
as.POSIXct(tstamp),
ignore_attr = "tzone"
)
+
+ tz <- "Pacific/Marquesas"
+ times <- seq(as.POSIXct("1999-02-07", tz = tz), as.POSIXct("2000-01-01", tz
= tz), by = "hour")
+ times <- c(as.POSIXct("1999-12-31T12:34:56.01", tz = "UTC"))
+
+ # The following formats are currently not supported by strptime: %q %Op
+ formats <- c("%a", "%A", "%b", "%B", "%d", "%H", "%j", "%m", "%Om", "%T",
"%OS", "%I%p",
+ "%S", "%q", "%M", "%p", "%U", "%w", "%W", "%y", "%Y", "%r",
"%R", "%T%z")
+ base_format <- c("%Y-%m-%d")
+
+ for (fmt in formats) {
+ fmt <- paste(base_format, fmt)
+ test_df <- tibble::tibble(x = strftime(times, format = fmt))
+ expect_equal(
+ test_df %>%
+ arrow_table() %>%
+ mutate(x = strptime(x, format = fmt)) %>%
+ collect(),
+ test_df %>%
+ mutate(x = strptime(x, format = fmt)) %>%
+ mutate(x = as.POSIXct(x)) %>%
Review Comment:
```suggestion
mutate(x = as.POSIXct(strptime(x, format = fmt))) %>%
```
##########
r/tests/testthat/test-dplyr-funcs-datetime.R:
##########
@@ -150,6 +150,30 @@ test_that("strptime", {
as.POSIXct(tstamp),
ignore_attr = "tzone"
)
+
+ tz <- "Pacific/Marquesas"
+ times <- seq(as.POSIXct("1999-02-07", tz = tz), as.POSIXct("2000-01-01", tz
= tz), by = "hour")
+ times <- c(as.POSIXct("1999-12-31T12:34:56.01", tz = "UTC"))
+
+ # The following formats are currently not supported by strptime: %q %Op
+ formats <- c("%a", "%A", "%b", "%B", "%d", "%H", "%j", "%m", "%Om", "%T",
"%OS", "%I%p",
+ "%S", "%q", "%M", "%p", "%U", "%w", "%W", "%y", "%Y", "%r",
"%R", "%T%z")
+ base_format <- c("%Y-%m-%d")
+
+ for (fmt in formats) {
+ fmt <- paste(base_format, fmt)
+ test_df <- tibble::tibble(x = strftime(times, format = fmt))
+ expect_equal(
+ test_df %>%
+ arrow_table() %>%
+ mutate(x = strptime(x, format = fmt)) %>%
+ collect(),
+ test_df %>%
+ mutate(x = strptime(x, format = fmt)) %>%
+ mutate(x = as.POSIXct(x)) %>%
Review Comment:
Why does this need `as.POSIXct()` and the top doesn't? (I'm sure it's fine,
I just want to make sure it's not covering up something).
--
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]