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

ITime column support #126

Closed
Giqles opened this issue Jan 19, 2018 · 3 comments
Closed

ITime column support #126

Giqles opened this issue Jan 19, 2018 · 3 comments
Assignees
Labels
Milestone

Comments

@Giqles
Copy link

Giqles commented Jan 19, 2018

It seems like ITime format columns are meant to be supported (eg, #82, #85, #17) but they don't seem to work correctly for me. Eg,

dt <- data.table(test = as.ITime(1:10, origin = "1970-01-01")) 
str(dt)
# Classes ‘data.table’ and 'data.frame':	10 obs. of  1 variable:
# $ test:Class 'ITime'  int [1:10] 1 2 3 4 5 6 7 8 9 10
# - attr(*, ".internal.selfref")=<externalptr>  
f <- tempfile()
write.fst(dt, f)
fst.metadata(f)
# <fst file>
# 10 rows, 1 columns (/tmp/RtmpuKW8XC/file9c394a829be5)
* 'test': ITime 
dt <- read.fst(f, as.data.table = T)
str(dt)
# Classes ‘data.table’ and 'data.frame':	10 obs. of  1 variable:
# $ test: int  1 2 3 4 5 6 7 8 9 10
# - attr(*, ".internal.selfref")=<externalptr>
@MarcusKlik
Copy link
Collaborator

Hi @Giqles, thanks for reporting that! Indeed, I see there is an attribute-test missing in the integer vector factory, well spotted. I will fix that as soon as possible!

@MarcusKlik
Copy link
Collaborator

The fst format allows for two ITime types; the integer and the double variant:

library(data.table)

x = as.ITime(1:10)
typeof(x)
#> [1] "integer"

x = 1.2:10.3
class(x) <- "ITime"
typeof(x)
#> [1] "double"

They are encoded with the INT_32_TIME_OF_DAY_SECONDS and DOUBLE_64_TIME_OF_DAY_SECONDS attributes this code. But upon reading, these attributes are not checked, so a default integer column is constructed.

@MarcusKlik
Copy link
Collaborator

The ITime attribute is now correctly implemented and available in the dev version, thanks for submitting your issue!

@MarcusKlik MarcusKlik self-assigned this Jan 19, 2018
@MarcusKlik MarcusKlik added this to the fst v0.8.4 milestone Jan 19, 2018
@MarcusKlik MarcusKlik added the bug label Jan 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants