| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Codecov Report
@@ Coverage Diff @@
## master #4944 +/- ##
=======================================
Coverage 99.42% 99.42%
=======================================
Files 73 73
Lines 14459 14461 +2
=======================================
+ Hits 14376 14378 +2
Misses 83 83
Continue to review full report at Codecov.
|
Sorry, something went wrong.
|
I thought about it some more and I guess aggregating a join makes sense? But I can't find documentation on it and the behaviour is somewhat unexpected to me. I played around with it a bit more and it works out as shorthand for slightly different join + group by operations: library('data.table')
x = data.table(id = 1:4, grp = c(2L, 1L, 2L, 1L), key = 'id')
y = data.table(id = 2:5, grp = c(2L, 1L, 2L, 1L), key = 'id')
all.equal(x[y, by=grp, .SD],
x[y, .(grp=x.grp, id=x.id)][, .SD, grp])
> [1] TRUE
all.equal(x[y, by=.(grp=x$grp), .SD],
x[y, .(grp=i.grp, id=x.id)][, .SD, grp])
> [1] TRUE
all.equal(x[y, .SD],
x[y, .(id=i.id, grp=x.grp)])
> [1] TRUEAlthough I haven't tried it for more complex examples.
Good old print debugging... The tooling on Windows can be a bit of a pain. |
Sorry, something went wrong.
|
Doh. Sorry for the mistake - I remembered that by = i.col but should have tested by = x.col before commenting. I think as long as data.table allows for column use from the parent.frame, there will just be some edge cases. The only other thought I have is to probe the by expression to try to determine if the variable is in the data.table. If the variable is in the parent.frame and !is.null(irows) then a warning might be good as it's unclear what the expected output should be. That is, would by = parent_frame_col be subsetted as well or would it be used as is. The last line of this is what explains the discrepancy. While x has been subsetted, the variable in the parent.frame has not been. Lines 790 to 800 in ec1259a |
Sorry, something went wrong.
|
Great fix! I confirmed the new test crashed for me too before this fix. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Closes #4892
So this fixes the reported segfault, but I'm not sure if there isn't something else that's going wrong. Slightly modifying @ColeMiller1's example, we get
Is that the correct behaviour? They can't both be correct, right? I'm not really sure what the intended purpose of grouping by a non-member column is. Maybe it would be better to catch this further up.
Also just as a remark, it's not necessary for this to be keyed join to trigger the sagfault.