dragosmg commented on a change in pull request #12431:
URL: https://github.com/apache/arrow/pull/12431#discussion_r811059343
##########
File path: r/tests/testthat/test-dplyr-funcs-datetime.R
##########
@@ -711,3 +711,40 @@ test_that("am/pm mirror lubridate", {
)
})
+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
+ )
+})
+
+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
+ )
Review comment:
I think, in this case, the error messages are fine. I think they are
good enough. However, and this is in relation with your follow-up questions, I
don't think they are very consistent. Take for example, calling the `"date"`
binding on a double:
```r
> call_binding("date", Scalar$create(32.2))
Error: NotImplemented: Unsupported cast from double to date32 using
function cast_date32
```
Some bindings are implemented at a higher and some at a lower level. Do we
want the error messaging to be consistent (or, better said, as consistent as it
could be)? If the answer is "Yes", then we might need to move that to R instead
of relying on the C++ code. Other benefits (until cpp11 supports classed
errors): handling errors (once generated) might be a bit easier.
--
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]