Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider vec_proxy() and vec_restore() methods for IDate #1781

Open
DavisVaughan opened this issue Feb 6, 2023 · 1 comment
Open

Consider vec_proxy() and vec_restore() methods for IDate #1781

DavisVaughan opened this issue Feb 6, 2023 · 1 comment
Labels
bug an unexpected problem or unintended behavior op:proxy-restore

Comments

@DavisVaughan
Copy link
Member

From tidyverse/dplyr#6687

library(vctrs)
library(data.table)

x <- as.IDate("2017-06-05")
class(x)
#> [1] "IDate" "Date"

typeof(x)
#> [1] "integer"

typeof(vec_slice(x, 1))
#> [1] "double"

# Because of
typeof(vec_proxy(x))
#> [1] "double"

# Proxy is inherited from Date, which normalizes to double
vctrs:::vec_proxy.Date
#> function (x, ...) 
#> {
#>     date_validate(x)
#> }
#> <bytecode: 0x7fedebbeb8f0>
#> <environment: namespace:vctrs>
@buggaby
Copy link

buggaby commented May 2, 2024

I'm seeing this occur with a filter call on a data.table. Is this the same issue?

Dates = as.IDate(c("2018-04-02", "2018-04-03", "2018-04-04"))
Letters = c("A", "B", "C")
dt = data.table(Date = Dates, Letter = Letters)

dt %>%
	pull(Date) %>%
	typeof()
#> [1] "integer"

dt %>%
	filter(Letter != "A") %>%
	pull(Date) %>%
	typeof()
#> [1] "double"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior op:proxy-restore
Projects
None yet
Development

No branches or pull requests

2 participants