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

Can't pillar_shaft() a nanotime column #378

Closed
DavisVaughan opened this issue Dec 16, 2021 · 3 comments · Fixed by #380
Closed

Can't pillar_shaft() a nanotime column #378

DavisVaughan opened this issue Dec 16, 2021 · 3 comments · Fixed by #380
Labels

Comments

@DavisVaughan
Copy link
Member

library(pillar)
library(nanotime)

x <- nanotime('2011-12-05 08:30:00.000', format ="%Y-%m-%d %H:%M:%E9S", tz ="GMT")

inherits(x, "integer64")
#> [1] TRUE

pillar_shaft(x)
#> Error in abs(x): non-numeric argument to mathematical function

Found in tidyverse/dplyr#6132

I'm not sure if this would immediately be "fixed" if nanotime supported abs(), or if more work than that is needed

@krlmlr
Copy link
Member

krlmlr commented Dec 22, 2021

Thanks. Introduced in b3aecf5: that commit added support for bit64 columns.

Should pillar_shaft.integer64() forward to the default behavior if called with a subclass?

@krlmlr krlmlr added the bug label Dec 22, 2021
krlmlr added a commit that referenced this issue Dec 22, 2021
- Fix support for `nanotime::nanotime()` classes (#378, #380).
@DavisVaughan
Copy link
Member Author

I think your fix makes sense.

I think in general it might make sense if pillar_shaft() worked sort of like vec_ptype2(). We don't allow inheritance in any way, so it will only recognize a method if the first class has a method, otherwise it falls back to a default operation. So this would have fallen back to a default because nanotime is a subclass of integer64 and the method search would stop after failing to find a method for nanotime

@github-actions
Copy link
Contributor

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants