Skip to content

ALTREP bug with explicitly sorted vectors as columns #2990

@Jakob-Bach

Description

@Jakob-Bach

When working with overlap joins, I encountered a bug that might be triggered by columns whose values are explicitly sorted with sort(). The bug seems to be rather related to some low-level functionality than the overlap join itself, but in the following I present a minimum reproducible example how I encountered the bug (the example per se does not make much sense; in my original code, I joined two different tables, but I keep it short here):

library(data.table)
myTable <- data.table(V1 = sort(rnorm(10000)))
myTable[, V2 := V1 + 1]
setkey(myTable)
foverlaps(myTable, myTable)

outputs Error in foverlaps(myTable, myTable) : Internal error in subset.c: column 1 is an ALTREP vector. Please see NEWS item 2 in v1.11.4 and report this as a bug. Using a different data generation statement than rnorm(...) did not make a difference in the examples I tried, but without sort(), the bug did not occur, even if the column was implicitly sorted (like V1 = 1:1000).

Output of sessionInfo():

R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] data.table_1.11.4

loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1    yaml_2.1.19 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions