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

fail to join by .EACHI when x has list in .SD and i has more elements in join column #2300

Closed
jangorecki opened this issue Aug 14, 2017 · 1 comment
Milestone

Comments

@jangorecki
Copy link
Member

@jangorecki jangorecki commented Aug 14, 2017

So if i data.table has more elements than x in a factor column used in join AND x data.table has a list column in .SD it will result an error. When factor in i does not have more elements OR x does not have a list column, issue will not occur:

library(data.table)
dt = data.table(a=factor(1:5, levels=1:10), b=as.list(letters[1:5]))
dt2 = data.table(a=as.factor(1:10))
dt[dt2, .SD, by=.EACHI, on="a", .SDcols="b"]
#Error in `[.data.table`(dt, dt2, .SD, by = .EACHI, on = "a", .SDcols = "b") : 
#  Logical error. Type of column should have been checked by now

dt2 = data.table(a=as.factor(1:5))
dt[dt2, .SD, by=.EACHI, on="a", .SDcols="b"]
# OK
dt = data.table(a=factor(1:5, levels=1:10), b=letters[1:5])
dt2 = data.table(a=as.factor(1:10))
dt[dt2, .SD, by=.EACHI, on="a", .SDcols="b"]
# OK
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

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

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

loaded via a namespace (and not attached):
[1] compiler_3.4.1
@franknarf1
Copy link
Contributor

@franknarf1 franknarf1 commented Aug 15, 2017

It's not such a special case, I guess, since a similar problem happens with other join cols besides factors:

library(data.table)
data.table(a = 1:2, b = list("yo", NULL))[.(1:3), on=.(a), x.b, by = .EACHI]
# Error in `[.data.table`(data.table(a = 1:2, b = list("yo", NULL)), .(1:3),  : 
#   Logical error. Type of column should have been checked by now

(Testing on 1.10.4. Sorry if this doesn't hold any more; I can't upgrade to dev here.)

@jangorecki jangorecki changed the title special case of join by .EACHI factor column and list in .SD fail fail to join by .EACHI when x has list in .SD and i has more elements in join column Aug 15, 2017
@jangorecki jangorecki added this to the v1.10.6 milestone Aug 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants