Skip to content

[Bug] data.table object with auto indexes saved under data.table 1.9.4 is not usable by data.table 1.9.6. #1396

@GRandom

Description

@GRandom

Apparently, 1.9.6 adds double underscore (__) to auto indexes and checks existence of these double underscores when accessing data.tables. However, 1.9.4. does not do either of these things. Thus, objects saved under 1.9.4 would not be usable under 1.9.6 and would throw an error in R. The bug will affect people who created and saved (perhaps, a lot of) objects under 1.9.4 and try to use them in later versions.

Minimal example:
Under R >3.2.1 and data.table <=1.9.4 run the following

abc.temp<-data.table(a=c(1,2),b=c(3,4))
abc.temp[a%in%c(1),b:=1]
save(abc.temp, file=”WhateverFolderWhateverFile.RData”)

str(abc.temp) output is:
Classes ‘data.table’ and 'data.frame': 2 obs. of 2 variables:
$ a: num 1 2
$ b: num 1 4

  • attr(*, ".internal.selfref")=
  • attr(, "index")= atomic
    ..- attr(
    , "a")= int

Under R>=3.2.1 and data.table 1.9.6 open the file and try to use the object
load(”WhateverFolderWhateverFile.RData”, verbose=TRUE)
abc.temp[,c:=5]

R throws error
Error in [.data.table(abc.temp, , :=(c, 5)) :
Internal error: __ not found in index name

The same code under data.table 1.9.6 gives auto index with underscore

abc.temp<-data.table(a=c(1,2),b=c(3,4))
abc.temp[a%in%c(1),b:=1]

str(abc.temp) output is
Classes ‘data.table’ and 'data.frame': 2 obs. of 2 variables:
$ a: num 1 2
$ b: num 1 4

  • attr(*, ".internal.selfref")=
    • attr(, "index")= atomic
      ..- attr(
      , "__a")= int

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions