-
Notifications
You must be signed in to change notification settings - Fork 986
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
Incorrect printing of integer64 columns #6224
Comments
Can verify the bug. library(fstcore)
library(data.table)
dt <- data.table(id = 1:10, int64 = bit64::as.integer64(1:10))
fst::write_fst(dt, "dt.fst") New R session: (dt <- fst::read_fst("dt.fst", as.data.table = TRUE))
(dt[, int64 := bit64::as.integer64(int64)])
At a first glance, it should probably be handled in the utility function for it as Line 53 in b7c5eaa
Looks like there has been an attempt to cover this and loading bit64 has been mentioned as a solution in the warning message there, but I don't think it's actually surfacing. Even a forced introduction of library(bit64) outside of the two conditions in that function doesn't seem to help as I just tested with such changes - After restarting the R session, it initially appears to be a function object as opposed to a data.table object:
str(dt)
# or just use dt for the definition along with bytecode + environment
(dt <- fst::read_fst("dt.fst", as.data.table = TRUE))
str(dt)
dt
sessionInfo()
|
You can use dt <- fst::read_fst("dt.fst", as.data.table = TRUE)
if(any(sapply(dt, inherits, "integer64")))
{
dt[, names(dt)[sapply(dt, inherits, "integer64")] := lapply(.SD, getNamespace("bit64")$as.integer64), .SDcols = sapply(dt, inherits, "integer64")]
}
dt
|
Seems related/duplicated to fstpackage/fst#267 |
This is not strictly related to another package: library(data.table)
DT=data.table(a=1, b=structure(1.06099789548264e-314, class = "integer64"))
DT
# a b
# <num> <i64>
# 1: 1 1.060998e-314
loadNamespace("bit64")
DT
# a b
# <num> <i64>
# 1: 1 2147483648 |
Here is a minimal reproducible example:
Start a new session without
bit64
being loaded.It looks like
fst::read_fst
does not loadbit64
automatically if there are integer64 columns in the data. I'm not sure if it better handled on data.table side: if the table contains integer64 columns,bit64
should be loaded inprint.data.table
.The text was updated successfully, but these errors were encountered: