eitsupi commented on code in PR #13890:
URL: https://github.com/apache/arrow/pull/13890#discussion_r946582180
##########
r/tests/testthat/test-dplyr-funcs-datetime.R:
##########
@@ -1899,24 +1900,52 @@ test_that("`as_datetime()`", {
ddate2 = lubridate::as_datetime(date),
dchar_date_no_tz = as_datetime(char_date),
dchar_date_with_tz = as_datetime(char_date, tz = "Pacific/Marquesas"),
+ dchar_date_subsec_no_tz = as_datetime(char_date_subsec),
+ dchar_date_subsec_with_tz = as_datetime(char_date_subsec, tz =
"Pacific/Marquesas"),
dint_date = as_datetime(int_date, origin = "1970-01-02"),
dintegerish_date = as_datetime(integerish_date, origin = "1970-01-02"),
- dintegerish_date2 = as_datetime(integerish_date, origin = "1970-01-01")
+ dintegerish_date2 = as_datetime(integerish_date, origin =
"1970-01-01"),
+ ddouble_date = as_datetime(double_date)
) %>%
collect(),
test_df
)
- # Arrow does not support conversion of double to date
- # the below should error with an error message originating in the C++ code
+ # Arrow does not support conversion of timestamp to int32
+ # ARROW-17428
expect_error(
test_df %>%
arrow_table() %>%
mutate(
- ddouble_date = as_datetime(double_date)
+ ddate = as_datetime(date),
+ ddate_int = as.integer(ddate)
) %>%
- collect(),
- regexp = "Float value 10.1 was truncated converting to int64"
+ compute(),
+ "Unsupported cast from timestamp\\[ns, tz=UTC\\] to int32 using function
cast_int32"
+ )
+
+ # Arrow does not support conversion of timestamp to double
+ # ARROW-17428
+ expect_error(
+ test_df %>%
+ arrow_table() %>%
+ mutate(
+ ddate = as_datetime(date),
+ ddate_num = as.numeric(ddate)
+ ) %>%
+ compute(),
+ "Unsupported cast from timestamp\\[ns, tz=UTC\\] to double using function
cast_double"
+ )
+
+ expect_error(
+ test_df %>%
+ arrow_table() %>%
+ mutate(
+ ddouble_date = as_datetime(double_date),
+ ddouble_date_date32 = as.Date(ddouble_date)
+ ) %>%
+ compute(),
+ "Casting from timestamp\\[ns, tz=UTC\\] to timestamp\\[s, tz=UTC\\] would
lose data: 10100000000"
Review Comment:
This error seems to occur only with `as.Date` and not with `as_date`.
I don't think this is the intended behavior, but given that `floor_date`
also exists, I don't know whether it is more appropriate to stop it by
generating an error or to floor it without permission.
--
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]