You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attached is a small zip archive of a saved data.table that demonstrates a problem where sometimes the [ operator gives misleading results.
load("./ff2") # from the path you extracted the archive to
dim(ff[symbol == "ZM" & date == 20210128])
# [1] 0 2 <---- wrong results, this subset is not empty
I agree with @tdeenes, raised this in the 2nd part of my comment above:
(2) setDF clears a few DT-only attributes, but notindex. That's very risky:
dt<- data.table(***)
# ... do stuff that creates indices
setDF(dt)
# ... do stuff that changes data, breaking the index
setDT(dt)
# index attribute is still there, but the data doesn't match.
The 1st half still worries me too, but it might be a different bug.
Also @jangorecki note that the update that uses <- is performed on a data.frame, not data.table.
Activity
tlapak commentedon Feb 3, 2021
OfekShilon commentedon Feb 3, 2021
tlapak commentedon Feb 3, 2021
OfekShilon commentedon Feb 4, 2021
jangorecki commentedon Feb 4, 2021
OfekShilon commentedon Feb 4, 2021
jangorecki commentedon Feb 4, 2021
[-]`[` gives wrong results[/-][+]`[.<-` invalidates index[/+]tdeenes commentedon Feb 4, 2021
I think the problem is with
setDFand not with the assignment. From the manual ofsetDF:The correct behaviour (and the adjusted doc) should read as:
OfekShilon commentedon Feb 4, 2021
I agree with @tdeenes, raised this in the 2nd part of my comment above:
The 1st half still worries me too, but it might be a different bug.
Also @jangorecki note that the update that uses
<-is performed on a data.frame, not data.table.OfekShilon commentedon Feb 4, 2021
Self contained repro (without loading anything, suitable for unit tests):
[-]`[.<-` invalidates index[/-][+]setDF should drop indices[/+]OfekShilon commentedon Feb 4, 2021
I created a single line PR for this