From 62ecb36612e9c2a4e6a9c8df396222b8122fcd93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99=20Moldovan-Gr=C3=BCnfeld?= Date: Tue, 15 Feb 2022 12:37:10 +0000 Subject: [PATCH 1/7] added unit test for `dst()` --- r/tests/testthat/test-dplyr-funcs-datetime.R | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/r/tests/testthat/test-dplyr-funcs-datetime.R b/r/tests/testthat/test-dplyr-funcs-datetime.R index c5de2684c02..2cc76d36f7a 100644 --- a/r/tests/testthat/test-dplyr-funcs-datetime.R +++ b/r/tests/testthat/test-dplyr-funcs-datetime.R @@ -784,5 +784,20 @@ test_that("semester works with temporal types and integers", { collect(), regexp = "NotImplemented: Function 'month' has no kernel matching input types (array[string])", fixed = TRUE + ) + }) + +test_that("dst extracts daylight savings time correctly", { + test_df <- tibble( + dates = as.POSIXct(c("2021-02-20", "2021-07-31", "2021-10-31", "2021-01-31"), tz = "Europe/London") + ) + # https://issues.apache.org/jira/browse/ARROW-13168 + skip_on_os("windows") + + compare_dplyr_binding( + .input %>% + mutate(dst = dst(dates)) %>% + collect(), + test_df ) }) From 91bb2215f97edbf85bcdaec1b469ecdadce0764b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99=20Moldovan-Gr=C3=BCnfeld?= Date: Tue, 15 Feb 2022 12:37:43 +0000 Subject: [PATCH 2/7] add `dst` to unary function map --- r/R/expression.R | 1 + 1 file changed, 1 insertion(+) diff --git a/r/R/expression.R b/r/R/expression.R index 0e71803ec97..224a46745e8 100644 --- a/r/R/expression.R +++ b/r/R/expression.R @@ -62,6 +62,7 @@ # date and time functions "day" = "day", + "dst" = "is_dst", "hour" = "hour", "isoweek" = "iso_week", "epiweek" = "us_week", From 39d89d3b20ae327a8d90132624b575f9df2eda60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99=20Moldovan-Gr=C3=BCnfeld?= Date: Tue, 15 Feb 2022 16:20:56 +0000 Subject: [PATCH 3/7] updated NEWS --- r/NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/r/NEWS.md b/r/NEWS.md index 20cae164445..84ef1c57579 100644 --- a/r/NEWS.md +++ b/r/NEWS.md @@ -22,6 +22,7 @@ * `lubridate`: * `tz()` to extract/get timezone * `semester()` to extract/get semester +* Additional `lubridate` features: `dst()`. # arrow 7.0.0 From 9b894c999e736631f2278f1f56bf5acf28b8b4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99=20Moldovan-Gr=C3=BCnfeld?= Date: Wed, 16 Feb 2022 17:04:40 +0000 Subject: [PATCH 4/7] add tests for unsupported types --- r/tests/testthat/test-dplyr-funcs-datetime.R | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/r/tests/testthat/test-dplyr-funcs-datetime.R b/r/tests/testthat/test-dplyr-funcs-datetime.R index 2cc76d36f7a..bf4b5c320d3 100644 --- a/r/tests/testthat/test-dplyr-funcs-datetime.R +++ b/r/tests/testthat/test-dplyr-funcs-datetime.R @@ -801,3 +801,26 @@ test_that("dst extracts daylight savings time correctly", { test_df ) }) + +test_that("dst errors with unsupported input", { + expect_error( + call_function("is_dst", Scalar$create("this is a string, not a timestamp")), + "NotImplemented: Function 'is_dst' has no kernel matching input types (scalar[string])", + fixed = TRUE + ) + expect_error( + call_function("is_dst", Scalar$create(1L)), + "NotImplemented: Function 'is_dst' has no kernel matching input types (scalar[int32])", + fixed = TRUE + ) + expect_error( + call_function("is_dst", Scalar$create(2.2)), + "NotImplemented: Function 'is_dst' has no kernel matching input types (scalar[double])", + fixed = TRUE + ) + expect_error( + call_function("is_dst", Scalar$create(TRUE)), + "NotImplemented: Function 'is_dst' has no kernel matching input types (scalar[bool])", + fixed = TRUE + ) +}) From 6c907d5cf4701d1843f3f0bfb9dafd9b968cf68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99=20Moldovan-Gr=C3=BCnfeld?= Date: Tue, 22 Feb 2022 14:31:34 +0000 Subject: [PATCH 5/7] NEWS --- r/NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/r/NEWS.md b/r/NEWS.md index 84ef1c57579..7bb2ab1d8bb 100644 --- a/r/NEWS.md +++ b/r/NEWS.md @@ -23,6 +23,7 @@ * `tz()` to extract/get timezone * `semester()` to extract/get semester * Additional `lubridate` features: `dst()`. + * `dst()` to get daylight savings time indicator. # arrow 7.0.0 From 57ef450779de7388ac6bef9910416108dd68188b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99=20Moldovan-Gr=C3=BCnfeld?= Date: Tue, 22 Feb 2022 15:00:10 +0000 Subject: [PATCH 6/7] remove type tests --- r/tests/testthat/test-dplyr-funcs-datetime.R | 23 -------------------- 1 file changed, 23 deletions(-) diff --git a/r/tests/testthat/test-dplyr-funcs-datetime.R b/r/tests/testthat/test-dplyr-funcs-datetime.R index bf4b5c320d3..2cc76d36f7a 100644 --- a/r/tests/testthat/test-dplyr-funcs-datetime.R +++ b/r/tests/testthat/test-dplyr-funcs-datetime.R @@ -801,26 +801,3 @@ test_that("dst extracts daylight savings time correctly", { test_df ) }) - -test_that("dst errors with unsupported input", { - expect_error( - call_function("is_dst", Scalar$create("this is a string, not a timestamp")), - "NotImplemented: Function 'is_dst' has no kernel matching input types (scalar[string])", - fixed = TRUE - ) - expect_error( - call_function("is_dst", Scalar$create(1L)), - "NotImplemented: Function 'is_dst' has no kernel matching input types (scalar[int32])", - fixed = TRUE - ) - expect_error( - call_function("is_dst", Scalar$create(2.2)), - "NotImplemented: Function 'is_dst' has no kernel matching input types (scalar[double])", - fixed = TRUE - ) - expect_error( - call_function("is_dst", Scalar$create(TRUE)), - "NotImplemented: Function 'is_dst' has no kernel matching input types (scalar[bool])", - fixed = TRUE - ) -}) From a8186292a83fc94b0aa2fe03326e141dacf74257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Drago=C8=99=20Moldovan-Gr=C3=BCnfeld?= Date: Wed, 23 Feb 2022 09:42:44 +0000 Subject: [PATCH 7/7] updated NEWS --- r/NEWS.md | 1 - 1 file changed, 1 deletion(-) diff --git a/r/NEWS.md b/r/NEWS.md index 7bb2ab1d8bb..c74916bf8cf 100644 --- a/r/NEWS.md +++ b/r/NEWS.md @@ -22,7 +22,6 @@ * `lubridate`: * `tz()` to extract/get timezone * `semester()` to extract/get semester -* Additional `lubridate` features: `dst()`. * `dst()` to get daylight savings time indicator. # arrow 7.0.0