paleolimbot opened a new pull request #11592:
URL: https://github.com/apache/arrow/pull/11592
Implements `is.Date()`, `is.POSIXct()`, `is.timepoint()`, and `is.instant()`
from the lubridate package.
There is also `lubridate::is.POSIXt()` and `lubridate::is.POSIXlt()`...these
are a bit more niche and I thought they might be confusing if implemented here.
Another question I had while implementing this...can/should these return an
`Expression$scalar()`? This isn't how the other `is.*()` functions are done but
maybe this makes a difference?
``` r
library(arrow, warn.conflicts = FALSE)
library(lubridate, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
test_date <- as.POSIXct("2017-01-01 00:00:11.3456789", tz =
"Pacific/Marquesas")
test_df <- tibble::tibble(
datetime = c(test_date, NA) + 1,
date = c(as.Date("2021-09-09"), NA)
)
RecordBatch$create(test_df) %>%
mutate(is.POSIXct(datetime), is.POSIXct(date)) %>%
collect()
#> # A tibble: 2 × 4
#> datetime date `is.POSIXct(datetime)` `is.POSIXct(date)`
#> <dttm> <date> <lgl> <lgl>
#> 1 2017-01-01 00:00:12 2021-09-09 TRUE FALSE
#> 2 NA NA TRUE FALSE
RecordBatch$create(test_df) %>%
mutate(is.Date(datetime), is.Date(date)) %>%
collect()
#> # A tibble: 2 × 4
#> datetime date `is.Date(datetime)` `is.Date(date)`
#> <dttm> <date> <lgl> <lgl>
#> 1 2017-01-01 00:00:12 2021-09-09 FALSE TRUE
#> 2 NA NA FALSE TRUE
RecordBatch$create(test_df) %>%
mutate(is.instant(datetime), is.instant(date)) %>%
collect()
#> # A tibble: 2 × 4
#> datetime date `is.instant(datetime)` `is.instant(date)`
#> <dttm> <date> <lgl> <lgl>
#> 1 2017-01-01 00:00:12 2021-09-09 TRUE TRUE
#> 2 NA NA TRUE TRUE
RecordBatch$create(test_df) %>%
mutate(is.timepoint(datetime), is.timepoint(date)) %>%
collect()
#> # A tibble: 2 × 4
#> datetime date `is.timepoint(datetime)`
`is.timepoint(date)`
#> <dttm> <date> <lgl> <lgl>
#> 1 2017-01-01 00:00:12 2021-09-09 TRUE TRUE
#> 2 NA NA TRUE TRUE
```
<sup>Created on 2021-11-02 by the [reprex
package](https://reprex.tidyverse.org) (v2.0.1)</sup>
--
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]