Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d6b66d2
first pass at implementing the binding for `lubridate::tz()`. needs m…
dragosmg Feb 7, 2022
ebc1443
`tz()` returns `"UTC"` for strings, date and NAs + more tests
dragosmg Feb 8, 2022
104c779
updated NEWS
dragosmg Feb 8, 2022
9710ffd
fall back to the simpler implementation for `tz()`
dragosmg Feb 10, 2022
38e38e0
split good and error behaviour in 2 different chunks and use `expect_…
dragosmg Feb 10, 2022
d88e4c9
update `tz()` binding to return `NA` when x is `NA`
dragosmg Feb 10, 2022
ff23580
update tests to reflect different behaviour for `NA`: arrow returns `…
dragosmg Feb 10, 2022
6014efa
revert to first / original implementation and remove NA propagation u…
dragosmg Feb 10, 2022
baaed40
updated unit tests and snapshots for `tz()`
dragosmg Feb 15, 2022
badcdb6
update `tz()` with more meaningful error messages
dragosmg Feb 15, 2022
f03ab7d
meaningful names for the test dataframe columns + update snapshots
dragosmg Feb 15, 2022
022070a
simplify the implementation (start with timestamp & error for anythin…
dragosmg Feb 15, 2022
d47fd4d
some clean up
jonkeane Feb 16, 2022
14d3ac4
removed snapshot md file
dragosmg Feb 17, 2022
52067c9
class extraction
dragosmg Feb 17, 2022
792f4ae
simplify class extraction once #12447 is merged
dragosmg Feb 17, 2022
d1d5946
first pass at implementing the binding for `lubridate::tz()`. needs m…
dragosmg Feb 7, 2022
91c5e66
`tz()` returns `"UTC"` for strings, date and NAs + more tests
dragosmg Feb 8, 2022
46080f6
updated NEWS
dragosmg Feb 8, 2022
0233ec5
fall back to the simpler implementation for `tz()`
dragosmg Feb 10, 2022
de7f992
split good and error behaviour in 2 different chunks and use `expect_…
dragosmg Feb 10, 2022
07c2a65
update `tz()` binding to return `NA` when x is `NA`
dragosmg Feb 10, 2022
0936441
update tests to reflect different behaviour for `NA`: arrow returns `…
dragosmg Feb 10, 2022
de648f4
revert to first / original implementation and remove NA propagation u…
dragosmg Feb 10, 2022
165031c
updated unit tests and snapshots for `tz()`
dragosmg Feb 15, 2022
30e2cea
update `tz()` with more meaningful error messages
dragosmg Feb 15, 2022
384fddc
meaningful names for the test dataframe columns + update snapshots
dragosmg Feb 15, 2022
af96552
simplify the implementation (start with timestamp & error for anythin…
dragosmg Feb 15, 2022
3cee34a
some clean up
jonkeane Feb 16, 2022
fa75502
removed snapshot md file
dragosmg Feb 17, 2022
4bf48f6
class extraction
dragosmg Feb 17, 2022
554345b
simplify class extraction once #12447 is merged
dragosmg Feb 17, 2022
3bff651
a few test additions|changes
jonkeane Feb 19, 2022
ea3a395
Merge branch 'lubridate_tz_binding' of https://github.com/dragosmg/ar…
dragosmg Feb 21, 2022
85c079c
update the `type` method for `Expression` to return a function + more…
dragosmg Feb 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions r/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

# arrow 7.0.0.9000

* `lubridate`:
* `tz()` to extract/get timezone

# arrow 7.0.0

## Enhancements to dplyr and datasets
Expand Down
6 changes: 6 additions & 0 deletions r/R/dplyr-funcs-datetime.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,11 @@ register_bindings_datetime <- function() {
register_binding("pm", function(x) {
!call_binding("am", x)
})
register_binding("tz", function(x) {
if (!call_binding("is.POSIXct", x)) {
abort(paste0("timezone extraction for objects of class `", type(x)$ToString(), "` not supported in Arrow"))
}

x$type()$timezone()
})
}
2 changes: 1 addition & 1 deletion r/R/type.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type.default <- function(x) Array__infer_type(x)
type.ArrowDatum <- function(x) x$type

#' @export
type.Expression <- function(x) x$type
type.Expression <- function(x) x$type()

#----- metadata

Expand Down
38 changes: 38 additions & 0 deletions r/tests/testthat/test-dplyr-funcs-datetime.R
Original file line number Diff line number Diff line change
Expand Up @@ -711,3 +711,41 @@ test_that("am/pm mirror lubridate", {
)

})

test_that("extract tz", {
df <- tibble(
posixct_date = as.POSIXct(c("2022-02-07", "2022-02-10"), tz = "Pacific/Marquesas"),
)

compare_dplyr_binding(
.input %>%
mutate(timezone_posixct_date = tz(posixct_date)) %>%
collect(),
df
)

# test a few types directly from R objects
expect_error(
call_binding("tz", "2020-10-01"),
"timezone extraction for objects of class `string` not supported in Arrow"
)
expect_error(
call_binding("tz", as.Date("2020-10-01")),
"timezone extraction for objects of class `date32[day]` not supported in Arrow",
fixed = TRUE
)
expect_error(
call_binding("tz", 1L),
"timezone extraction for objects of class `int32` not supported in Arrow"
)
expect_error(
call_binding("tz", 1.1),
"timezone extraction for objects of class `double` not supported in Arrow"
)

# Test one expression
expect_error(
call_binding("tz", Expression$scalar("2020-10-01")),
"timezone extraction for objects of class `string` not supported in Arrow"
)
})
9 changes: 6 additions & 3 deletions r/tests/testthat/test-type.R
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ test_that("type() gets the right type for Expression", {
y <- Expression$scalar(10)
add_xy <- Expression$create("add", x, y)

expect_equal(x$type, type(x))
expect_equal(y$type, type(y))
expect_equal(add_xy$type, type(add_xy))
expect_equal(x$type(), type(x))
expect_equal(type(x), int32())
expect_equal(y$type(), type(y))
expect_equal(type(y), float64())
expect_equal(add_xy$type(), type(add_xy))
expect_equal(type(add_xy), float64())
})